예제 #1
0
		private Bug421071Test.TopLevelScope CreateGlobalScope()
		{
			factory = new Bug421071Test.DynamicScopeContextFactory();
			Context context = factory.EnterContext();
			// noinspection deprecation
			Bug421071Test.TopLevelScope globalScope = new Bug421071Test.TopLevelScope(this, context);
			Context.Exit();
			return globalScope;
		}
예제 #2
0
파일: Utils.cs 프로젝트: hazzik/Rhino.Net
		/// <summary>Runs the provided action at the given optimization level</summary>
		public static void RunWithOptimizationLevel(ContextFactory contextFactory, ContextAction action, int optimizationLevel)
		{
			Context cx = contextFactory.EnterContext();
			try
			{
				cx.SetOptimizationLevel(optimizationLevel);
				action.Run(cx);
			}
			finally
			{
				Context.Exit();
			}
		}
		public virtual void TestSetNullForScriptableSetter()
		{
			string scriptCode = "foo.myProp = new Foo2();\n" + "foo.myProp = null;";
			ContextFactory factory = new ContextFactory();
			Context cx = factory.EnterContext();
			try
			{
				ScriptableObject topScope = cx.InitStandardObjects();
				CustomSetterAcceptNullScriptableTest.Foo foo = new CustomSetterAcceptNullScriptableTest.Foo();
				// define custom setter method
				MethodInfo setMyPropMethod = typeof(CustomSetterAcceptNullScriptableTest.Foo).GetMethod("setMyProp", typeof(CustomSetterAcceptNullScriptableTest.Foo2));
				foo.DefineProperty("myProp", null, null, setMyPropMethod, ScriptableObject.EMPTY);
				topScope.Put("foo", topScope, foo);
				ScriptableObject.DefineClass<CustomSetterAcceptNullScriptableTest.Foo2>(topScope);
				cx.EvaluateString(topScope, scriptCode, "myScript", 1, null);
			}
			finally
			{
				Context.Exit();
			}
		}
예제 #4
0
		public virtual void TestStrictModeError()
		{
			contextFactory = new StrictModeApiTest.MyContextFactory();
			Context cx = contextFactory.EnterContext();
			try
			{
				global = cx.InitStandardObjects();
				try
				{
					RunScript("({}.nonexistent);");
					NUnit.Framework.Assert.Fail();
				}
				catch (EvaluatorException e)
				{
					NUnit.Framework.Assert.IsTrue(e.Message.StartsWith("Reference to undefined property"));
				}
			}
			finally
			{
				Context.Exit();
			}
		}