コード例 #1
0
ファイル: lexfuncs.go プロジェクト: ole108/diamond-lang
func scanSpecialCall(fullId common.SrcPiece) (id string, halfApplied bool) {
	buf := strings.Bytes(fullId.Content())
	i := 0
	if buf[i] == '\\' {
		halfApplied = true
		i++
	}
	id = string(buf[i:len(buf)])
	return
}
コード例 #2
0
ファイル: srcbuf_test.go プロジェクト: ole108/diamond-lang
func testSrcPiece(piece common.SrcPiece, line int, column int,
	content string, wholeLine string, t *testing.T, num int) {
	failed := false
	if piece.StartLine() != line {
		failed = true
		t.Errorf("(%d) Expected line %d but got %d.", num, line, piece.StartLine())
	}
	if piece.StartColumn() != column {
		failed = true
		t.Errorf("(%d) Expected column %d but got %d.", num, column, piece.StartColumn())
	}
	if piece.Content() != content {
		failed = true
		t.Errorf("(%d) Expected content `%v` but got `%v`.", num, content, piece.Content())
	}
	if piece.WholeLine() != wholeLine {
		failed = true
		t.Errorf("(%d) Expected wholeLine `%v` but got `%v`.", num, wholeLine, piece.WholeLine())
	}
	if failed {
		t.FailNow()
	}
}