-
Notifications
You must be signed in to change notification settings - Fork 859
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix for Map/Set working with ConsString as key also; closes #583
- Loading branch information
Showing
4 changed files
with
126 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
load("testsrc/assert.js"); | ||
|
||
res = ""; | ||
|
||
function logElement(value, key) { | ||
res += "set[" + key + "] "; | ||
} | ||
|
||
(function TestForEach() { | ||
res = "a) "; | ||
var mySet = new Set(['key1', 17]); | ||
mySet.forEach(logElement); | ||
|
||
assertEquals("a) set[key1] set[17] ", res); | ||
})(); | ||
|
||
(function TestForEachNoKey() { | ||
res = "b) "; | ||
var mySet = new Set(['', undefined, null, 19]); | ||
mySet.forEach(logElement); | ||
|
||
assertEquals("b) set[] set[undefined] set[null] set[19] ", res); | ||
})(); | ||
|
||
(function TestAddConcatenatedStrings() { | ||
var mySet = new Set(['key1']); | ||
var mySet2 = new Set(['key2']); | ||
for(let i = 1; i <= 1; i++) { | ||
let key = 'key' + i; | ||
|
||
assertEquals(1, mySet.size); | ||
mySet.add(key) | ||
assertEquals(1, mySet.size); | ||
|
||
assertEquals(1, mySet2.size); | ||
mySet2.add(key) | ||
assertEquals(2, mySet2.size); | ||
} | ||
})(); | ||
|
||
(function TestHasConcatenatedStrings() { | ||
var mySet = new Set(['key1', 'key2']); | ||
for(let i = 1; i <= 1; i++) { | ||
let key = 'key' + i; | ||
|
||
assertTrue(mySet.has(key)); | ||
assertTrue(mySet.has('key1')); | ||
} | ||
})(); | ||
|
||
(function TestDeleteConcatenatedStrings() { | ||
var mySet = new Set(['key1', 'key2']); | ||
for(let i = 1; i <= 1; i++) { | ||
let key = 'key' + i; | ||
|
||
assertEquals(2, mySet.size); | ||
mySet.delete(key) | ||
assertEquals(1, mySet.size); | ||
} | ||
})(); | ||
|
||
"success"; |
16 changes: 16 additions & 0 deletions
16
testsrc/org/mozilla/javascript/tests/es6/NativeSetTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
package org.mozilla.javascript.tests.es6; | ||
|
||
import org.mozilla.javascript.Context; | ||
import org.mozilla.javascript.drivers.LanguageVersion; | ||
import org.mozilla.javascript.drivers.RhinoTest; | ||
import org.mozilla.javascript.drivers.ScriptTestsBase; | ||
|
||
@RhinoTest("testsrc/jstests/es6/set.js") | ||
@LanguageVersion(Context.VERSION_ES6) | ||
public class NativeSetTest extends ScriptTestsBase | ||
{ | ||
} |