|
1 | 1 | /* |
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. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 | 4 | * |
5 | 5 | * The Universal Permissive License (UPL), Version 1.0 |
@@ -171,19 +171,6 @@ public void testIntersectionHasNotCallable() { |
171 | 171 | } |
172 | 172 | } |
173 | 173 |
|
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 | | - |
187 | 174 | @Test |
188 | 175 | public void testIntersectionIsNotSet() { |
189 | 176 | try (Context context = getNewSetMethodsContext()) { |
@@ -236,19 +223,6 @@ public void testDifferenceEmptyOutput() { |
236 | 223 | } |
237 | 224 | } |
238 | 225 |
|
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 | | - |
252 | 226 | @Test |
253 | 227 | public void testDifferenceIsNotSet() { |
254 | 228 | try (Context context = getNewSetMethodsContext()) { |
@@ -301,41 +275,6 @@ public void testSymmetricDifferenceEmptyOutput() { |
301 | 275 | } |
302 | 276 | } |
303 | 277 |
|
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 | | - |
339 | 278 | @Test |
340 | 279 | public void testSymmetricDifferenceIsNotSet() { |
341 | 280 | try (Context context = getNewSetMethodsContext()) { |
@@ -374,25 +313,26 @@ public void testIsNotSubsetOf() { |
374 | 313 | @Test |
375 | 314 | public void testIsSubsetOfNoIterable() { |
376 | 315 | 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;" + |
378 | 317 | "set1.isSubsetOf(x);", |
379 | 318 | createSetString(3, 5)); |
380 | 319 | context.eval(JavaScriptLanguage.ID, code); |
381 | | - Assert.fail("Should not be Iterable."); |
| 320 | + Assert.fail("Should not be Set-like."); |
382 | 321 | } catch (PolyglotException ex) { |
383 | | - assertTrue(ex.getMessage().contains("TypeError: 0 is not iterable")); |
| 322 | + assertTrue(ex.getMessage().startsWith("TypeError:")); |
384 | 323 | } |
385 | 324 | } |
386 | 325 |
|
387 | 326 | @Test |
388 | 327 | public void testIsSubsetOfIterableHasNotCallable() { |
389 | 328 | 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;" + |
391 | 330 | "set1.isSubsetOf(arr);", |
392 | 331 | 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")); |
396 | 336 | } |
397 | 337 | } |
398 | 338 |
|
@@ -431,19 +371,6 @@ public void testIsNotSupersetOf() { |
431 | 371 | } |
432 | 372 | } |
433 | 373 |
|
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 | | - |
447 | 374 | @Test |
448 | 375 | public void testIsSupersetOfIsNotSet() { |
449 | 376 | try (Context context = getNewSetMethodsContext()) { |
@@ -482,7 +409,7 @@ public void testIsNotDisjointFrom() { |
482 | 409 | @Test |
483 | 410 | public void testIsDisjointFromHasNotCallable() { |
484 | 411 | 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;" + |
486 | 413 | "set1.isDisjointFrom(arr);", |
487 | 414 | createSetString(1, 2)); |
488 | 415 | context.eval(JavaScriptLanguage.ID, code); |
|
0 commit comments