Skip to content

Commit 0232fbc

Browse files
committed
add test for bindings.removeMember()
1 parent 2500fac commit 0232fbc

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
package com.oracle.truffle.js.test.polyglot;
4242

4343
import static org.junit.Assert.assertEquals;
44+
import static org.junit.Assert.assertFalse;
4445
import static org.junit.Assert.assertTrue;
4546

4647
import java.util.Collections;
@@ -160,4 +161,18 @@ public String toString() {
160161
return "string";
161162
}
162163
}
164+
165+
@Test
166+
public void testRemoveBindings() {
167+
try (Context context = JSTest.newContextBuilder().build()) {
168+
Value bindings = context.getBindings("js");
169+
assertTrue(bindings.removeMember("eval"));
170+
171+
assertFalse(bindings.hasMember("foo"));
172+
context.eval(JavaScriptLanguage.ID, "foo=42;");
173+
assertTrue(bindings.hasMember("foo"));
174+
assertTrue(bindings.removeMember("foo"));
175+
assertFalse(bindings.hasMember("foo"));
176+
}
177+
}
163178
}

0 commit comments

Comments
 (0)