@@ -522,4 +522,89 @@ public void ProxyIterateClrList()
522522
523523        Assert . Equal ( [ 1 ,  2 ,  3 ,  3 ] ,  res . AsArray ( ) ) ; 
524524    } 
525+ 
526+     [ Fact ] 
527+     public  void  ProxyClrObjectMethod ( ) 
528+     { 
529+         var  res  =  _engine 
530+             . SetValue ( "T" ,  new  TestClass ( ) ) 
531+             . Evaluate ( """ 
532+                  const handler = { 
533+                      get(target, property, receiver) { 
534+ 
535+                          if (property == "Add") { 
536+                              return function(...args) { return 42}; 
537+                          } 
538+ 
539+                          return Reflect.get(...arguments); 
540+                      } 
541+                  }; 
542+ 
543+                  const p = new Proxy(T, handler); 
544+                  p.Add(5,3); // throws 'get' on proxy: property 'Add' is a read-only and non-configurable data property 
545+                              // on the proxy target but the proxy did not return its actual value 
546+                              // (expected 'function Jint.Tests.Runtime.ProxyTests+TestClass.Add() { [native code] }' but got 'function () { [native code] }') 
547+              """ ) ; 
548+ 
549+         Assert . Equal ( 42 ,  res . AsInteger ( ) ) ; 
550+     } 
551+ 
552+     [ Fact ] 
553+     public  void  ProxyClrObjectMethodWithDelegate ( ) 
554+     { 
555+         var  res  =  _engine 
556+             . SetValue ( "T" ,  new  TestClass ( ) ) 
557+             . Evaluate ( """ 
558+                  const handler = { 
559+                      get(target, property, receiver) { 
560+ 
561+                          if (property == "Add") { 
562+                              return (...args) => 42; 
563+                          } 
564+ 
565+                          return Reflect.get(...arguments); 
566+                      } 
567+                  }; 
568+ 
569+                  const p = new Proxy(T, handler); 
570+                  p.Add(5,3); // throws 'get' on proxy: property 'Add' is a read-only and non-configurable data property 
571+                              // on the proxy target but the proxy did not return its actual value 
572+                              // (expected 'function Jint.Tests.Runtime.ProxyTests+TestClass.Add() { [native code] }' but got 'function () { [native code] }') 
573+              """ ) ; 
574+ 
575+         Assert . Equal ( 42 ,  res . AsInteger ( ) ) ; 
576+     } 
577+ 
578+     [ Fact ] 
579+     public  void  ProxyClrObjectWithTmpObjectMethod ( ) 
580+     { 
581+         var  res  =  _engine 
582+             . SetValue ( "T" ,  new  TestClass ( ) ) 
583+             . Evaluate ( """ 
584+                  const handler = { 
585+                      get(target, property, receiver) { 
586+ 
587+                          if (property == "Add") { 
588+                              return (...args) => target.target[property](...args) + 34; 
589+                          } 
590+ 
591+                          if (typeof target.target[property] === "function") 
592+                             return (...args) => target.target[property](...args); 
593+ 
594+                         return Reflect.get(target.target, property, receiver) 
595+                      } 
596+                  }; 
597+ 
598+                  const tmpObj = { target: T }; 
599+                  const p = new Proxy(tmpObj, handler); 
600+ 
601+                  const name = p.Name; 
602+                  p.SayHello(); 
603+                  const res = p.Add(5,3); // works now 
604+ 
605+                  name + " " + res 
606+              """ ) ; 
607+ 
608+         Assert . Equal ( "My Name is Test 42" ,  res . AsString ( ) ) ; 
609+     } 
525610} 
0 commit comments