public void ImportType() { SRM.ImportType(typeof(Contact)); string script = @" var t = debug.assert; var contact = new Contact(); contact.name = 'reo'; t( contact.phoneNumbers != null ); contact.phoneNumbers.add('01-234-567'); t( contact.name, 'reo' ); t( contact.phoneNumbers.length, 1 ); t( contact.phoneNumbers[0], '01-234-567' ); // access invisible property contact.remark = 'comment'; t( contact.remark, null ); "; SRM.Run(script); }
public void AccessProperty() { // import using alias SRM.ImportType(typeof(Friut), "MyClass"); SRM.Run(@" var t = debug.assert; var apple = new MyClass(); apple.name = 'apple'; t(apple.name, 'apple'); apple.Color = 'red'; apple.Price = 1.95; t(apple.color, 'red'); t(apple.price, 1.95); t(apple.color + ' ' + apple.price, 'red 1.95'); t( apple['name'], 'apple' ); t( apple['Color'], 'red' ); t( apple['color'], 'red' ); t( apple['price'], '1.95' ); "); }
public void CLRArrayIndexNumber() { int[] arr = new int[10]; for (int i = 0; i < arr.Length; i++) { arr[i] = i; } SRM["arr"] = arr; SRM.Run(@" debug.assert(arr.length, 10); for(var i=0;i<arr.length;i++) { debug.assert( arr[i], i ); }"); SRM["myarr"] = new MyArrayStub(); SRM.Run(@" debug.assert(myarr.length, 10); for(var i=0;i<myarr.length;i++) { myarr[i] = i; debug.assert( myarr[i], i ); }"); }
public void EventBindTest() { var c = new EventStub(); SRM["c"] = c; SRM.Run(@" var t = debug.assert; t( c.DummyEvent, null ); var a = 10; c.DummyEvent = function() { a = 20; }; debug.assertTrue( c.DummyEvent != null, 'event not be attached' ); "); c.RaiseEvent(); SRM.Run(@" t( a, 20 ); t( c.DummyEvent != null ); c.DummyEvent = null; debug.assertTrue( c.DummyEvent == null, 'event not be detached.' ); "); }
[TestCase(Disabled = true)] // Not Supported Yet public void InnerClasssAccess() { SRM.ImportType(typeof(StaticA.StaticB)); SRM.Run(@" debug.assert( Test.StaticA.StaticB != null ); debug.assert( new StaticB() != null ); "); }
public void FuncCall() { SRM["myfunc"] = (System.Func <int, int, int>)((a, b) => { return(a + b); }); SRM.Run(@"debug.assert( myfunc(1, 2), 3 );"); }
public void IDictionaryEnumeration() { // import using alias SRM["obj"] = new Stuff(); SRM.Run(@" "); }
void DictionaryAccess() { Dictionary <string, object> dic = new Dictionary <string, object>(); dic["name"] = "hello"; SRM["myobj"] = dic; SRM.Run(@" debug.assert( myobj.name, 'hello' ); "); }
public void StaticMemberModify() { SRM.ImportType(typeof(StaticClassTest)); SRM.Run(@" debug.assert( StaticClassTest != null ); debug.assert( StaticClassTest.a, 10 ); StaticClassTest.a = 20; debug.assert( StaticClassTest.a, 20 ); "); }
public void ImportNamespace() { SRM.ImportNamespace("System.Windows.Forms"); SRM.ImportNamespace("System.Drawing"); SRM.Run(@" var t = debug.assert; t( Color != null ); t( Color.Red != null ); "); }
public void StaticMemberAccess() { SRM.ImportType(typeof(System.Drawing.Color)); SRM.Run(@" debug.assert(Color.Yellow, 'Color [Yellow]'); debug.assert(System.Drawing.SystemColors.Control != null); debug.assert(Color.Yellow, System.Drawing.Color.Yellow); "); }
public void CLRArrayPrototype() { int[] arr = { 1, 2, 3, 4, 5 }; SRM["arr"] = arr; SRM.Run(@" var t = debug.assert; t( arr[0], 1 ); t( arr.length, 5 ); t( arr.join('.'), '1.2.3.4.5' ); "); }
public void ImportAndCreate() { SRM.ImportType(typeof(Friut)); SRM.Run(@" var t = debug.assert; var apple = new Friut(); t(typeof apple, 'native object'); t(apple instanceof Friut); "); }
public void AccessLowercaseMethod() { // import using alias SRM.ImportType(typeof(Friut), "MyClass"); SRM.Run(@" var t = debug.assert; var apple = new MyClass(); var c = apple.methodInLowercase(5, 6); t(c, 11); "); }
public void ImportAndCreate2() { // import using alias SRM.ImportType(typeof(Friut), "MyClass"); SRM.Run(@" var t = debug.assert; var apple = new MyClass(); t(typeof apple, 'native object'); t(apple instanceof MyClass); "); }
public void AccessMethod() { // import using alias SRM.ImportType(typeof(Friut), "MyClass"); SRM.Run(@" var t = debug.assert; var apple = new MyClass(); apple.shipOut(); t(apple.isShippedOut, true); "); }
public void CLRArrayIndexString() { SRM["myarr"] = new MyArrayStub(); SRM.Run(@" for(var i=0;i<myarr.length;i++) { myarr['item'+i] = i; debug.assert( myarr['item'+i], i ); }"); SRM["mylist"] = new MyListStub(); SRM.Run(@" for(var i=0;i<mylist.length;i++) { mylist['item' + i] = i; debug.assert( mylist['item'+ i], i ); }"); }
public void NewKeyword() { SRM.ImportType(typeof(ArrayList)); SRM.Run(@" var arr1 = new ArrayList(); debug.assert( arr1 != null ); var arr2 = new ArrayList; debug.assert( arr2 != null ); var alias = ArrayList; debug.assert( new alias() != null ); debug.assert( new alias != null ); "); }
public void IDictionarySupport() { // import using alias SRM["obj"] = new Stuff(); SRM.Run(@" var t = debug.assert; var date = new Date(); obj.name = 'red alert'; obj.startTime = date; t(obj.name, 'red alert'); t(obj.startTime, date); "); }
public void ExtendedObjectValue() { var extObj = new MyObjectValue(); SRM["extObj"] = extObj; SRM.Run("extObj.testProp = 'a';"); TestCaseAssertion.AssertTrue(extObj.ValueSetted); // true TestCaseAssertion.AssertTrue(!extObj.ValueGetted); // false SRM.Run("var a = extObj.testProp;"); TestCaseAssertion.AssertTrue(extObj.ValueSetted); // true TestCaseAssertion.AssertTrue(extObj.ValueGetted); // true extObj = new MyObjectValue(); //SRM.Run("extObj.testProp = 'a';"); TestCaseAssertion.AssertTrue(!extObj.ValueSetted); // true TestCaseAssertion.AssertTrue(!extObj.ValueGetted); // false }
public void FieldAndEventMember() { SRM["c"] = new Contact(); SRM.Run(@" var t = debug.assert; c.fieldMember = 10; t( c.fieldMember, 10 ); c.eventMember = function(){ this.fieldMember = 20; }; "); ((Contact)SRM["c"]).RaiseEventMember(); SRM.Run(@" var t = debug.assert; t( c.fieldMember, 20 ); c.eventMember = null; // remove event c.fieldMember = 10; "); ((Contact)SRM["c"]).RaiseEventMember(); SRM.Run(@" var t = debug.assert; t( c.fieldMember, 10 ); "); }
public void IDictionaryEnumeration() { // import using alias SRM["obj"] = new Stuff(); SRM.Run(@" var t = debug.assert; var date = new Date(); obj.name = 'red alert'; obj.startTime = date; var o = ''; for(name in obj) { o+=name + ' '; } t(o, 'name startTime '); "); }
public void EventTest() { SRM["c"] = new Contact(); SRM.Run(@" var t = debug.assert; t( c.EventMember, null ); var a = 10; c.EventMember = function() { a = 20; }; t( c.EventMember != null ); "); ((Contact)SRM["c"]).RaiseEventMember(); SRM.Run(@" t( a, 20 ); t( c.EventMember != null ); c.EventMember = null; t( c.EventMember, null ); "); }
public void ComparingOperators() { // import using alias SRM.ImportType(typeof(Friut), "MyClass"); SRM.Run(@" var t = debug.assert; var apple = new MyClass(); apple.price = 1.95; t(apple.price <= 1.95); t(apple.price >= 1.95); t(apple.price == 1.95); t(apple.price == '1.95'); // compare to string t(apple.price === 1.95); apple.price = 2.1; t(apple.price === 2.1); "); }