Ejemplo n.º 1
0
		public TestClass() {
			AccModTest = new AccessModifierTest();
			ArrTest = new ArrayTest();
			ETest = new EnumTest();
			IdentTest = new IdentifierTest();
			MethTest = new MethodTest();
			SpecExpTest = new SpecialExpressionsTest();
			AssignTest = new AssignmentTest();
			OpEqTest = new OpEqTest();
			Suffixes = new Suffixes();
			Constants = new TermConstants();
			Override = new OverrideTest();
			OpOver1 = new OpOverload();
			OpOver2 = new OpOverload();
		}
Ejemplo n.º 2
0
 public TestClass()
 {
     AccModTest  = new AccessModifierTest();
     ArrTest     = new ArrayTest();
     ETest       = new EnumTest();
     IdentTest   = new IdentifierTest();
     MethTest    = new MethodTest();
     SpecExpTest = new SpecialExpressionsTest();
     AssignTest  = new AssignmentTest();
     OpEqTest    = new OpEqTest();
     Suffixes    = new Suffixes();
     Constants   = new TermConstants();
     Override    = new OverrideTest();
     OpOver1     = new OpOverload();
     OpOver2     = new OpOverload();
 }
        public void TestLetStatements()
        {
            string input = @"
                let x = 5;
                let y = 10;
                let foobar = 838383;
";

            Lexer  lexer  = new Lexer(input);
            Parser parser = new Parser(lexer);

            Program program = parser.ParseProgram();

            checkParserErrors(parser);

            if (program == null)
            {
                Assert.Fail("ParseProgram() returned nil");
            }
            if (program.Statements.Count != 3)
            {
                Assert.Fail($"program.Statements  does not contain 3 statements. got {program.Statements.Count}");
            }

            IdentifierTest[] identifierTests = new IdentifierTest[]
            {
                new IdentifierTest("x"),
                new IdentifierTest("y"),
                new IdentifierTest("foobar")
            };

            for (int i = 0; i < identifierTests.Length; i++)
            {
                IStatement stmt = program.Statements[i];
                TestLetStatements(stmt, identifierTests[i].expectedIdentifier);
            }
        }
Ejemplo n.º 4
0
 // Does it qualify for Lua's identifier rules?
 private static Boolean CanBeIdentifier(String Input)
 {
     return(IdentifierTest.IsMatch(Input));
 }