示例#1
0
        public void StringTest() {
            TryCompile(@"context Tournament 
inv: 'a'='a'");

            TypesTable tt = new TypesTable();
            StandardLibraryCreator sLC = new StandardLibraryCreator();
            sLC.CreateStandardLibrary(tt);

            Compiler compiler = new Compiler();
            Exolutio.Model.OCL.Environment env = new NamespaceEnvironment(tt.Library.RootNamespace);
            testString(compiler, tt, env, "''", "");
            testString(compiler, tt, env, "'a'", "a");
            testString(compiler, tt, env, "'aa'", "aa");
            testString(compiler, tt, env, "'\\b'", "\b");
            testString(compiler, tt, env, "'\\t'", "\t");
            testString(compiler, tt, env, "'\\n'", "\n");
            testString(compiler, tt, env, "'\\f'", "\f");
            testString(compiler, tt, env, "'\\r'", "\r");
            testString(compiler, tt, env, "'\\\"'", "\"");
            testString(compiler, tt, env, "'\\''", "'");
            testString(compiler, tt, env, "'\\x27'", "\x27");
            testString(compiler, tt, env, "'\\u1127'", "\x1127");
            testString(compiler, tt, env, @"'\\t'", @"\t");
            testString(compiler, tt, env, @"'\\\t'", "\\\t");
            testString(compiler, tt, env, @"'\\\\t'", "\\\\t");
            testString(compiler, tt, env, @"'\\\\\t'", "\\\\\t");
            testString(compiler, tt, env, @"'\\\\\\t'", "\\\\\\t");
        }
        public void SimpleExpression()
        {
            TypesTable             tt  = new TypesTable();
            StandardLibraryCreator sLC = new StandardLibraryCreator();

            sLC.CreateStandardLibrary(tt);

            Compiler compiler = new Compiler();

            Exolutio.Model.OCL.Environment env = new NamespaceEnvironment(tt.Library.RootNamespace);
            var res = compiler.CompileStandAloneExpression("1=1", tt, env);

            Assert.IsFalse(res.Errors.HasError);
            Assert.AreEqual(typeof(OperationCallExp), res.Expression.GetType());
        }