Skip to content

Commit a20b17f

Browse files
committed
extend ForeignTestMap test coverage
1 parent 90377df commit a20b17f

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

graal-js/src/com.oracle.truffle.js.test/src/com/oracle/truffle/js/test/polyglot/ForeignTestMapTest.java

+20-1
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,16 @@
4040
*/
4141
package com.oracle.truffle.js.test.polyglot;
4242

43+
import static org.junit.Assert.assertEquals;
4344
import static org.junit.Assert.assertFalse;
4445
import static org.junit.Assert.assertTrue;
4546

4647
import org.junit.Test;
4748

4849
import com.oracle.truffle.js.runtime.JSRuntime;
50+
import com.oracle.truffle.js.test.JSTest;
4951

50-
public class ForeignTestMapTest {
52+
public class ForeignTestMapTest extends JSTest {
5153

5254
@Test
5355
public void equalTest() {
@@ -67,4 +69,21 @@ public void equalTest() {
6769
assertFalse(JSRuntime.equal(a, 0));
6870
assertFalse(JSRuntime.equal(a, true));
6971
}
72+
73+
@Test
74+
public void foreignTestMapTests() {
75+
ForeignTestMap map = new ForeignTestMap();
76+
map.getContainer().put("value", "boxed");
77+
78+
testHelper.getPolyglotContext().getBindings("js").putMember("foreign", map);
79+
80+
assertEquals("boxed", testHelper.run("foreign.value"));
81+
assertEquals(42, testHelper.run("foreign.othervalue=42"));
82+
assertEquals(42, testHelper.run("foreign.othervalue"));
83+
assertEquals(true, testHelper.run("delete foreign.othervalue"));
84+
assertEquals(true, testHelper.run("foreign.othervalue === undefined"));
85+
assertEquals(84, testHelper.run("foreign.fn = (a)=>{ return a+a; }; foreign.fn(42);"));
86+
87+
assertEquals(true, testHelper.run("foreign.length=10; foreign[0]=42; foreign[1]=41; Array.prototype.sort.call(foreign); foreign[0]===41 && foreign[1]===42 && foreign[2]===undefined;"));
88+
}
7089
}

0 commit comments

Comments
 (0)