Exemple #1
0
 public static double BaseExtensionBindTestMethod <T>(this BaseTestObject self, T arg)
 {
     return(TestUtil.CalcTestValue(new Guid("fdef26a4-2155-4be5-a245-4810ae66c491"), self, typeof(T), arg));
 }
 public void StaticMemberAccess_Field_Scalar_Overflow()
 {
     TestUtil.AssertException <OverflowException>(() => engine.Execute("StaticTestClass.StaticScalarField = 54321"));
 }
Exemple #3
0
 public void BugFix_NullArgBinding_Ambiguous()
 {
     engine.AddHostObject("lib", new HostTypeCollection("mscorlib"));
     TestUtil.AssertException <RuntimeBinderException>(() => engine.Execute("lib.System.Console.WriteLine(null)"));
 }
 public void StaticMemberAccess_Method_Generic_TypeArgConstraintFailure()
 {
     TestUtil.AssertException <RuntimeBinderException>(() => engine.Execute("StaticTestClass.StaticMethod('foo', 4, StaticTestClass)"));
 }
 public void StaticMemberAccess_Method_GenericExplicit_MissingTypeArg()
 {
     TestUtil.AssertException <RuntimeBinderException>(() => engine.Execute("StaticTestClass.StaticMethod(4)"));
 }
 public void StaticMemberAccess_Property_Enum_BadAssignment()
 {
     TestUtil.AssertException <ArgumentException>(() => engine.Execute("StaticTestClass.StaticEnumProperty = 1"));
 }
 public void StaticMemberAccess_ReadOnlyProperty_Write()
 {
     TestUtil.AssertException <UnauthorizedAccessException>(() => engine.Execute("StaticTestClass.StaticReadOnlyProperty = 2"));
 }
 public void BaseMemberAccess_Field_Scalar_BadAssignment()
 {
     TestUtil.AssertException <ArgumentException>(() => engine.Execute("testObject.BaseScalarField = TestEnum.Second"));
 }
Exemple #9
0
 public void InterfaceMemberAccess_Property_BadAssignment()
 {
     TestUtil.AssertException <ArgumentException>(() => engine.Execute("testObject.InterfaceProperty = host.newArr(System.Double, 5)"));
 }
 public void BaseMemberAccess_Field_BadAssignment()
 {
     TestUtil.AssertException <ArgumentException>(() => engine.Execute("testObject.BaseField = host.newArr(System.Double, 5)"));
 }
 public void BaseMemberAccess_Field_Scalar_Overflow()
 {
     TestUtil.AssertException <OverflowException>(() => engine.Execute("testObject.BaseScalarField = 54321"));
 }
 public void BaseMemberAccess_ReadOnlyProperty_Write()
 {
     TestUtil.AssertException <UnauthorizedAccessException>(() => engine.Execute("testObject.BaseReadOnlyProperty = 2"));
 }
 public void BaseMemberAccess_Field_Struct_BadAssignment()
 {
     TestUtil.AssertException <ArgumentException>(() => engine.Execute("testObject.BaseStructField = System.DateTime.Now"));
 }
 public void BaseMemberAccess_Field_Enum_BadAssignment()
 {
     TestUtil.AssertException <ArgumentException>(() => engine.Execute("testObject.BaseEnumField = 1"));
 }
Exemple #15
0
 public void InterfaceMemberAccess_ExtensionMethod_GenericRedundant_MismatchedTypeArg()
 {
     TestUtil.AssertException <RuntimeBinderException>(() => engine.Execute("testObject.InterfaceExtensionMethod(System.Int32, 'foo', 4, TestEnum.Second)"));
 }
Exemple #16
0
 public void InterfaceMemberAccess_Property_Scalar_Overflow()
 {
     TestUtil.AssertException <OverflowException>(() => engine.Execute("testObject.InterfaceScalarProperty = 54321"));
 }
Exemple #17
0
 public void InterfaceMemberAccess_ExtensionMethod_GenericExplicit_MissingTypeArg()
 {
     TestUtil.AssertException <RuntimeBinderException>(() => engine.Execute("testObject.InterfaceExtensionMethod(4)"));
 }
Exemple #18
0
 public void InterfaceMemberAccess_Property_Scalar_BadAssignment()
 {
     TestUtil.AssertException <ArgumentException>(() => engine.Execute("testObject.InterfaceScalarProperty = TestEnum.Second"));
 }
 public void StaticMemberAccess_Property_Struct_BadAssignment()
 {
     TestUtil.AssertException <ArgumentException>(() => engine.Execute("StaticTestClass.StaticStructProperty = System.DateTime.Now"));
 }
Exemple #20
0
 public void InterfaceMemberAccess_Property_Enum_BadAssignment()
 {
     TestUtil.AssertException <ArgumentException>(() => engine.Execute("testObject.InterfaceEnumProperty = 1"));
 }
 public void StaticMemberAccess_Method_NoMatchingOverload()
 {
     TestUtil.AssertException <RuntimeBinderException>(() => engine.Execute("StaticTestClass.StaticMethod('foo', TestEnum.Second)"));
 }
Exemple #22
0
 public void InterfaceMemberAccess_Property_Struct_BadAssignment()
 {
     TestUtil.AssertException <ArgumentException>(() => engine.Execute("testObject.InterfaceStructProperty = System.DateTime.Now"));
 }
 public void StaticMemberAccess_Method_GenericRedundant_MismatchedTypeArg()
 {
     TestUtil.AssertException <RuntimeBinderException>(() => engine.Execute("StaticTestClass.StaticMethod(System.Int32, 'foo', 4, TestEnum.Second)"));
 }
Exemple #24
0
 public void InterfaceMemberAccess_ReadOnlyProperty_Write()
 {
     TestUtil.AssertException <ArgumentException>(() => engine.Execute("testObject.InterfaceReadOnlyProperty = 2"));
 }
 public void StaticMemberAccess_Field_BadAssignment()
 {
     TestUtil.AssertException <ArgumentException>(() => engine.Execute("StaticTestClass.StaticField = host.newArr(System.Double, 5)"));
 }
Exemple #26
0
 public void InterfaceMemberAccess_ExtensionMethod_NoMatchingOverload()
 {
     TestUtil.AssertException <RuntimeBinderException>(() => engine.Execute("testObject.InterfaceExtensionMethod('foo', TestEnum.Second)"));
 }
 public void StaticMemberAccess_Field_Scalar_BadAssignment()
 {
     TestUtil.AssertException <ArgumentException>(() => engine.Execute("StaticTestClass.StaticScalarField = TestEnum.Second"));
 }
Exemple #28
0
 public void InterfaceMemberAccess_ExtensionMethod_Generic_TypeArgConstraintFailure()
 {
     TestUtil.AssertException <RuntimeBinderException>(() => engine.Execute("testObject.InterfaceExtensionMethod('foo', 4, testObject)"));
 }
Exemple #29
0
        public void JScriptModule_CommonJS_Context()
        {
            engine.DocumentSettings.AccessFlags = DocumentAccessFlags.EnableFileLoading;
            engine.DocumentSettings.Loader      = new CustomLoader();

            Assert.AreEqual(123, engine.Evaluate(new DocumentInfo {
                Category = ModuleCategory.CommonJS
            }, @"
                var Geometry = require('JavaScript/LegacyCommonJS/Geometry/Geometry');
                return Geometry.Meta.foo;
            "));

            Assert.AreEqual(456.789, engine.Evaluate(new DocumentInfo {
                Category = ModuleCategory.CommonJS
            }, @"
                var Geometry = require('JavaScript/LegacyCommonJS/Geometry/Geometry');
                return Geometry.Meta.bar;
            "));

            Assert.AreEqual("bogus", engine.Evaluate(new DocumentInfo {
                Category = ModuleCategory.CommonJS
            }, @"
                var Geometry = require('JavaScript/LegacyCommonJS/Geometry/Geometry');
                return Geometry.Meta.baz;
            "));

            Assert.IsInstanceOfType(engine.Evaluate(new DocumentInfo {
                Category = ModuleCategory.CommonJS
            }, @"
                var Geometry = require('JavaScript/LegacyCommonJS/Geometry/Geometry');
                return new Geometry.Meta.qux();
            "), typeof(Random));

            Assert.IsInstanceOfType(engine.Evaluate(new DocumentInfo {
                Category = ModuleCategory.CommonJS
            }, @"
                var Geometry = require('JavaScript/LegacyCommonJS/Geometry/Geometry');
                return Geometry.Meta.quux;
            "), typeof(Undefined));

            Assert.AreEqual(Math.PI, engine.Evaluate(new DocumentInfo {
                Category = ModuleCategory.CommonJS
            }, @"
                var Arithmetic = require('JavaScript/LegacyCommonJS/Arithmetic/Arithmetic');
                return Arithmetic.Meta.foo;
            "));

            Assert.IsInstanceOfType(engine.Evaluate(new DocumentInfo {
                Category = ModuleCategory.CommonJS
            }, @"
                var Arithmetic = require('JavaScript/LegacyCommonJS/Arithmetic/Arithmetic');
                return Arithmetic.Meta.bar;
            "), typeof(Undefined));

            engine.DocumentSettings.SearchPath = string.Join(";",
                                                             Path.Combine(Directory.GetCurrentDirectory(), "JavaScript", "LegacyCommonJS", "Arithmetic"),
                                                             Path.Combine(Directory.GetCurrentDirectory(), "JavaScript", "LegacyCommonJS", "Geometry")
                                                             );

            TestUtil.AssertException <UnauthorizedAccessException>(() => engine.Execute(new DocumentInfo {
                Category = ModuleCategory.CommonJS
            }, @"
                var Geometry = require('GeometryWithPathlessImport');
            "));
        }
Exemple #30
0
 public static double BaseExtensionMethod <T>(this BaseTestObject self, int arg) where T : struct
 {
     return(TestUtil.CalcTestValue(new Guid("2db0feaf-8618-4676-a7ba-552a20853fcd"), self, typeof(T).Name.Length, arg));
 }