Exemplo n.º 1
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]));
        }
Exemplo n.º 2
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]));
        }
Exemplo n.º 3
0
        public void testAnonymousAnyTypeWithAttribute()
        {
            // any x with attribute name
            IdentifierList list     = new IdentifierList("name");
            IParameter     argument = new ExtendedParameter(AnyType.Instance, "x", list);

            argument.register(context);
            IType st = argument.GetIType(context);

            Assert.IsTrue(st is CategoryType);
            Assert.IsFalse(st.isAssignableFrom(context, BooleanType.Instance));
            Assert.IsFalse(st.isAssignableFrom(context, IntegerType.Instance));
            Assert.IsFalse(st.isAssignableFrom(context, DecimalType.Instance));
            Assert.IsFalse(st.isAssignableFrom(context, TextType.Instance));
            Assert.IsFalse(st.isAssignableFrom(context, DateType.Instance));
            Assert.IsFalse(st.isAssignableFrom(context, DateTimeType.Instance));
            Assert.IsFalse(st.isAssignableFrom(context, MissingType.Instance));
            Assert.IsFalse(st.isAssignableFrom(context, AnyType.Instance));                     // any type never compatible
            Assert.IsTrue(st.isAssignableFrom(context, new CategoryType("Simple")));            // since Simple has a name
            Assert.IsFalse(st.isAssignableFrom(context, new CategoryType("Root")));             // since Root has no name
            Assert.IsFalse(st.isAssignableFrom(context, new CategoryType("DerivedWithOther"))); // since DerivedWithOther has no name
            Assert.IsTrue(st.isAssignableFrom(context, new CategoryType("DerivedWithName")));   // since DerivedWithName has a name
        }