Exemple #1
0
        public void testMethod1Parameter1Statement()
        {
            String statement = "define printName as method receiving Person p doing:\r\n"
                               + "\tprint with \"person\" + p.name as value";
            ETestParser parser           = new ETestParser(statement, false);
            ConcreteMethodDeclaration ad = parser.parse_concrete_method_declaration();

            Assert.IsNotNull(ad);
            Assert.AreEqual("printName", ad.GetName());
            Assert.IsNotNull(ad.getParameters());
            Assert.IsTrue(ad.getParameters().Contains(new CategoryParameter(new CategoryType("Person"), "p")));
            Assert.IsNotNull(ad.getStatements());
            Assert.AreEqual("print with \"person\" + p.name as value", generate(ad.getStatements()[0]));
        }
Exemple #2
0
        public void testMethod1Array1Statement()
        {
            String statement = "define printName as method receiving Option[] options doing:\r\n"
                               + "\tprint with \"array\" + args as value";
            ETestParser parser           = new ETestParser(statement, false);
            ConcreteMethodDeclaration ad = parser.parse_concrete_method_declaration();

            Assert.IsNotNull(ad);
            Assert.AreEqual("printName", ad.GetName());
            Assert.IsNotNull(ad.getParameters());
            IParameter expected = new CategoryParameter(new ListType(new CategoryType("Option")), "options");

            Assert.IsTrue(ad.getParameters().Contains(expected));
            Assert.IsNotNull(ad.getStatements());
            Assert.AreEqual("print with \"array\" + args as value", generate(ad.getStatements()[0]));
        }
Exemple #3
0
        public void testMethod1Extended1Statement()
        {
            String statement = "define printName as method receiving Object o with attribute name doing:\r\n"
                               + "\tprint with \"object\" + o.name as value";
            ETestParser parser           = new ETestParser(statement, false);
            ConcreteMethodDeclaration ad = parser.parse_concrete_method_declaration();

            Assert.IsNotNull(ad);
            Assert.AreEqual("printName", ad.GetName());
            Assert.IsNotNull(ad.getParameters());
            IParameter expected = new ExtendedParameter(new CategoryType("Object"), "o", new IdentifierList("name"));

            Assert.IsTrue(ad.getParameters().Contains(expected));
            Assert.IsNotNull(ad.getStatements());
            Assert.AreEqual("print with \"object\" + o.name as value", generate(ad.getStatements()[0]));
        }