Skip to content

Commit 39cd5b1

Browse files
committed
Updating NewSetMethodsTest.
1 parent 2831bf8 commit 39cd5b1

File tree

1 file changed

+10
-83
lines changed

1 file changed

+10
-83
lines changed

graal-js/src/com.oracle.truffle.js.test/src/com/oracle/truffle/js/test/builtins/NewSetMethodsTest.java

Lines changed: 10 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -171,19 +171,6 @@ public void testIntersectionHasNotCallable() {
171171
}
172172
}
173173

174-
@Test
175-
public void testIntersectionAddNotCallable() {
176-
try (Context context = getNewSetMethodsContext()) {
177-
String code = String.format("var set1 = %s; var set2 = %s; Set.prototype.add = 17;" +
178-
"var result = set1.intersection(set2);",
179-
createSetString(1, 2, 3, 4), createSetString(3, 4, 5, 6));
180-
context.eval(JavaScriptLanguage.ID, code);
181-
Assert.fail("Non callable expected.");
182-
} catch (PolyglotException ex) {
183-
assertTrue(ex.getMessage().contains("TypeError: Callable expected"));
184-
}
185-
}
186-
187174
@Test
188175
public void testIntersectionIsNotSet() {
189176
try (Context context = getNewSetMethodsContext()) {
@@ -236,19 +223,6 @@ public void testDifferenceEmptyOutput() {
236223
}
237224
}
238225

239-
@Test
240-
public void testDifferenceDeleteNotCallable() {
241-
try (Context context = getNewSetMethodsContext()) {
242-
String code = String.format("var set1 = %s; var set2 = %s; Set.prototype.delete = 17;" +
243-
"set1.difference(set2);",
244-
createSetString(1, 2, 3, 4), createSetString(3, 4, 5, 6));
245-
context.eval(JavaScriptLanguage.ID, code);
246-
Assert.fail("Non callable expected.");
247-
} catch (PolyglotException ex) {
248-
assertTrue(ex.getMessage().contains("TypeError: Callable expected"));
249-
}
250-
}
251-
252226
@Test
253227
public void testDifferenceIsNotSet() {
254228
try (Context context = getNewSetMethodsContext()) {
@@ -301,41 +275,6 @@ public void testSymmetricDifferenceEmptyOutput() {
301275
}
302276
}
303277

304-
@Test
305-
public void testSymmetricDifferenceDeleteNotCallable() {
306-
try (Context context = getNewSetMethodsContext()) {
307-
String code = String.format("var set1 = %s; var set2 = %s; Set.prototype.delete = 17;" +
308-
"set1.symmetricDifference(set2);",
309-
createSetString(1, 2, 3, 4), createSetString(3, 4, 5, 6));
310-
context.eval(JavaScriptLanguage.ID, code);
311-
Assert.fail("Non callable expected.");
312-
} catch (PolyglotException ex) {
313-
assertTrue(ex.getMessage().contains("TypeError: Callable expected"));
314-
}
315-
}
316-
317-
@Test
318-
public void testSymmetricDifferenceAddNotCallable() {
319-
try (Context context = getNewSetMethodsContext()) {
320-
String code = String.format("var set1 = %s; var set2 = %s; Set.prototype.add = 666;" +
321-
"set1.symmetricDifference(set2);",
322-
createSetString(1, 2, 3, 4), createSetString(3, 4, 5, 6));
323-
context.eval(JavaScriptLanguage.ID, code);
324-
Assert.fail("Non callable expected.");
325-
} catch (PolyglotException ex) {
326-
assertTrue(ex.getMessage().contains("TypeError:"));
327-
}
328-
try (Context context = getNewSetMethodsContext()) {
329-
String code = String.format("var set1 = %s; var set2 = %s; delete(Set.prototype.add);" +
330-
"set1.symmetricDifference(set2);",
331-
createSetString(1, 2, 3, 4), createSetString(3, 4, 5, 6));
332-
context.eval(JavaScriptLanguage.ID, code);
333-
Assert.fail("Non callable expected.");
334-
} catch (PolyglotException ex) {
335-
assertTrue(ex.getMessage().contains("TypeError:"));
336-
}
337-
}
338-
339278
@Test
340279
public void testSymmetricDifferenceIsNotSet() {
341280
try (Context context = getNewSetMethodsContext()) {
@@ -374,25 +313,26 @@ public void testIsNotSubsetOf() {
374313
@Test
375314
public void testIsSubsetOfNoIterable() {
376315
try (Context context = getNewSetMethodsContext()) {
377-
String code = String.format("var set1 = %s; var x = 0; Array.prototype.has = 17;" +
316+
String code = String.format("var set1 = %s; var x = 0;" +
378317
"set1.isSubsetOf(x);",
379318
createSetString(3, 5));
380319
context.eval(JavaScriptLanguage.ID, code);
381-
Assert.fail("Should not be Iterable.");
320+
Assert.fail("Should not be Set-like.");
382321
} catch (PolyglotException ex) {
383-
assertTrue(ex.getMessage().contains("TypeError: 0 is not iterable"));
322+
assertTrue(ex.getMessage().startsWith("TypeError:"));
384323
}
385324
}
386325

387326
@Test
388327
public void testIsSubsetOfIterableHasNotCallable() {
389328
try (Context context = getNewSetMethodsContext()) {
390-
String code = String.format("var set1 = %s; var arr = [3, 4, 5, 6]; Array.prototype.has = 17;" +
329+
String code = String.format("var set1 = %s; var arr = [3, 4, 5, 6]; arr.size = arr.length; Array.prototype.has = 17;" +
391330
"set1.isSubsetOf(arr);",
392331
createSetString(3, 5));
393-
Value result = context.eval(JavaScriptLanguage.ID, code);
394-
assertTrue(result.isBoolean());
395-
assertTrue(result.asBoolean());
332+
context.eval(JavaScriptLanguage.ID, code);
333+
Assert.fail("Non callable expected.");
334+
} catch (PolyglotException ex) {
335+
assertTrue(ex.getMessage().contains("TypeError: Callable expected"));
396336
}
397337
}
398338

@@ -431,19 +371,6 @@ public void testIsNotSupersetOf() {
431371
}
432372
}
433373

434-
@Test
435-
public void testIsSupersetOfIterableHasNotCallable() {
436-
try (Context context = getNewSetMethodsContext()) {
437-
String code = String.format("var set1 = %s; var arr = [3, 6]; Set.prototype.has = 17;" +
438-
"set1.isSupersetOf(arr);",
439-
createSetString(3, 4, 5, 6));
440-
context.eval(JavaScriptLanguage.ID, code);
441-
Assert.fail("Non callable expected.");
442-
} catch (PolyglotException ex) {
443-
assertTrue(ex.getMessage().contains("TypeError: Callable expected"));
444-
}
445-
}
446-
447374
@Test
448375
public void testIsSupersetOfIsNotSet() {
449376
try (Context context = getNewSetMethodsContext()) {
@@ -482,7 +409,7 @@ public void testIsNotDisjointFrom() {
482409
@Test
483410
public void testIsDisjointFromHasNotCallable() {
484411
try (Context context = getNewSetMethodsContext()) {
485-
String code = String.format("var set1 = %s; var arr = [3, 4]; Set.prototype.has = 17;" +
412+
String code = String.format("var set1 = %s; var arr = [3, 4]; arr.size = arr.length; Set.prototype.has = 17;" +
486413
"set1.isDisjointFrom(arr);",
487414
createSetString(1, 2));
488415
context.eval(JavaScriptLanguage.ID, code);

0 commit comments

Comments
 (0)