Skip to content

Commit

Permalink
BL-738
Browse files Browse the repository at this point in the history
  • Loading branch information
bdw429s committed Nov 4, 2024
1 parent 86f2b15 commit dfe4cec
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,4 +175,13 @@ public boolean requiresStrictArguments() {
return true;
}

/**
* If we are wrapping a BIF that outputs something, don't block it
*
* @param context The context in which the function is being invoked
*/
public boolean canOutput( FunctionBoxContext context ) {
return true;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,13 @@ public boolean requiresStrictArguments() {
return true;
}

/**
* If we are wrapping a method that outputs something, don't block it
*
* @param context The context in which the function is being invoked
*/
public boolean canOutput( FunctionBoxContext context ) {
return true;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -186,4 +186,13 @@ public boolean requiresStrictArguments() {
return true;
}

/**
* If we are wrapping a method that outputs something, don't block it
*
* @param context The context in which the function is being invoked
*/
public boolean canOutput( FunctionBoxContext context ) {
return true;
}

}
14 changes: 14 additions & 0 deletions src/test/java/TestCases/phase1/CoreLangTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3755,4 +3755,18 @@ function testMe( string foo ) {
assertThat( variables.get( result ) ).isNull();
}


@Test
public void testPassingBLFunctionsToJavaMethods() {
instance.executeSource(
"""
import java.lang.System;
[1,2,3].stream().forEach( ::echo )
// Lambdas/closures have output=false by default in BL code.
[1,2,3].stream().forEach( (i) output=true -> echo(i) )
result = getBoxContext().getBuffer().toString();
""", context );
assertThat( variables.get( result ) ).isEqualTo( "123123" );
}

}

0 comments on commit dfe4cec

Please sign in to comment.