@@ -89,9 +89,16 @@ public void assertEvaluate(Object expectedReturnValue, String script) {
8989 // TODO: Refactor things so we can check evalCps as well.
9090 }
9191
92- public void assertIntercept (String script , Object expectedResult , String ... expectedInterceptions ) throws Throwable {
92+ public void assertIntercept (String script , Object expectedResult , String ... expectedCalls ) throws Throwable {
9393 assertEvaluate (expectedResult , script );
94- ec .checkThat (cr .toString ().split ("\n " ), equalTo (expectedInterceptions ));
94+ String [] updatedExpectedCalls = expectedCalls ;
95+ // Insert SerializableScript constructor call automatically to avoid having to update all tests.
96+ if (expectedCalls .length == 0 || (expectedCalls .length > 0 && !expectedCalls [0 ].equals ("new SerializableScript()" ))) {
97+ updatedExpectedCalls = new String [expectedCalls .length + 1 ];
98+ updatedExpectedCalls [0 ] = "new SerializableScript()" ;
99+ System .arraycopy (expectedCalls , 0 , updatedExpectedCalls , 1 , expectedCalls .length );
100+ }
101+ ec .checkThat (cr .toString ().split ("\n " ), equalTo (updatedExpectedCalls ));
95102 }
96103
97104 /**
@@ -566,7 +573,8 @@ public void nonCpsfinalizerForbidden() throws Throwable {
566573 null ,
567574 "Script1.super(Script1).setBinding(Binding)" ,
568575 "new Test()" ,
569- "System:getProperties()" );
576+ "System:getProperties()" ,
577+ "new Test(Properties)" );
570578 }
571579
572580 @ Ignore ("Initial expressions for parameters in CPS-transformed closures are currently ignored" )
@@ -636,6 +644,7 @@ public void sandboxInterceptsImplicitCastsArrayAssignment() throws Throwable {
636644 "Script3.super(Script3).setBinding(Binding)" ,
637645 "new Test()" ,
638646 "new File(String)" ,
647+ "new Test(File)" ,
639648 "Test.x" );
640649 }
641650
0 commit comments