Пример #1
0
        public void parsesMethod1Parameter1Statement()
        {
            String      statement        = "method printName ( Person p ) { print ( value = \"person\" + p.name); }";
            OTestParser parser           = new OTestParser(statement);
            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(value = \"person\" + p.name)", generate(ad.getStatements()[0]));
        }
Пример #2
0
        public void parsesMethod1Array1Statement()
        {
            String      statement        = "method printName ( Option[] options ) { print ( value = \"array\" + options ); }";
            OTestParser parser           = new OTestParser(statement);
            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(value = \"array\" + options)", generate(ad.getStatements()[0]));
        }
Пример #3
0
        public void parsesMethod1Extended1Statement()
        {
            String      statement        = "method printName ( Object(name) o ) { print ( value = \"object\" + o.name ); }";
            OTestParser parser           = new OTestParser(statement);
            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(value = \"object\" + o.name)", generate(ad.getStatements()[0]));
        }