示例#1
0
func TestBlankType(t *testing.T) {
	lexer := new(compiler.Lexer).Init("class A { }")
	parser := new(compiler.Parser).Init(lexer)
	node := parser.TypeDecl()

	class := CLASS(IDENT("A"), MEMBERS())
	if node.String() != class {
		t.Fatalf("CLASS not parsed")
	}
}
示例#2
0
func TestTypeWithMainMethod(t *testing.T) {
	lexer := new(compiler.Lexer).Init(
		"\n" +
			"class A {\n" +
			"   static main(args){\n" +
			"   }\n" +
			"}\n")
	parser := new(compiler.Parser).Init(lexer)
	node := parser.TypeDecl()

	args := ARGS(ARG(TYPE("java.lang.Object"), IDENT("args"), NIL))
	mainMethod := METHOD(
		MODIFIERS(STATIC),
		NIL,
		IDENT("main"),
		args,
		"METHOD_BODY")
	class := CLASS(IDENT("A"), MEMBERS(mainMethod))

	if node.String() != class {
		t.Fatalf("CLASS not parsed")
	}
}