Exemplo n.º 1
0
        public virtual void testOverrideScriptSource()
        {
            // when a script is created and executed
            SourceExecutableScript script = CreateScript(SCRIPT_LANGUAGE, EXAMPLE_SCRIPT);

            Assert.NotNull(script);
            ExecuteScript(script);

            // it was compiled
            Assert.IsFalse(script.IsShouldBeCompiled());
            Assert.NotNull(script.CompiledScript);

            // if the script source changes
            script.SetScriptSource(EXAMPLE_SCRIPT);

            // then it should not be compiled after change
            Assert.True(script.IsShouldBeCompiled());
            Assert.IsNull(script.CompiledScript);

            // but after next execution
            ExecuteScript(script);

            // it is compiled again
            Assert.IsFalse(script.IsShouldBeCompiled());
            Assert.NotNull(script.CompiledScript);
        }
Exemplo n.º 2
0
        public virtual void testScriptShouldBeCompiledByDefault()
        {
            // when a script is created
            SourceExecutableScript script = CreateScript(SCRIPT_LANGUAGE, EXAMPLE_SCRIPT);

            Assert.NotNull(script);

            // then it should not be compiled on creation
            Assert.True(script.IsShouldBeCompiled());
            Assert.IsNull(script.CompiledScript);

            // but after first execution
            ExecuteScript(script);

            // it was compiled
            Assert.IsFalse(script.IsShouldBeCompiled());
            Assert.NotNull(script.CompiledScript);
        }
Exemplo n.º 3
0
        public virtual void testDisableScriptCompilationByDisabledScriptEngineCaching()
        {
            // when script engine caching is disabled and a script is created
            processEngineConfiguration.SetEnableScriptEngineCaching(false);
            SourceExecutableScript script = CreateScript(SCRIPT_LANGUAGE, EXAMPLE_SCRIPT);

            Assert.NotNull(script);

            // then it should not be compiled on creation
            Assert.True(script.IsShouldBeCompiled());
            Assert.IsNull(script.CompiledScript);

            // and after first execution
            ExecuteScript(script);

            // it was also not compiled
            Assert.IsFalse(script.IsShouldBeCompiled());
            Assert.IsNull(script.CompiledScript);

            // re-enable script engine caching
            processEngineConfiguration.SetEnableScriptEngineCaching(true);
        }