8000 Merge pull request #46 from scala-wasm/arraylist-test · scala-wasm/scala-wasm@aa23cb0 · GitHub
[go: up one dir, main page]

Skip to content

Commit aa23cb0

Browse files
authored
Merge pull request #46 from scala-wasm/arraylist-test
Add ju.ArrayList tests / fix boxed double equality for signed zeros
2 parents eae0066 + dcdbdc8 commit aa23cb0

File tree

3 files changed

+88
-1
lines changed

3 files changed

+88
-1
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package testSuiteWASI
2+
3+
import org.scalajs.testsuite.javalib.util.{ListTest, CollectionTest}
4+
import org.scalajs.testsuite.javalib.lang.IterableTest
5+
6+
object AbstractTests {
7+
def runListTests(test: ListTest) = {
8+
import test._
9+
addStringGetIndex()
10+
addIntGetIndex()
11+
addDoubleGetIndex()
12+
addCustomObjectsGetIndex()
13+
removeStringRemoveIndex()
14+
removeDoubleOnCornerCases()
15+
clearList()
16+
containsStringList()
17+
containedDoubleOnCornerCases()
18+
setString()
19+
test.iterator()
20+
toArrayObjectForList()
21+
toArraySpecificForList()
22+
listIterator()
23+
listIteratorPreviousThrowsNoSuchElementException()
24+
addIndex()
25+
indexOf()
26+
lastIndexOf()
27+
indexOfLastIndexOfDoubleCornerCases()
28+
subListBackedByList()
29+
iteratorSetRemoveIfAllowed()
30+
replaceAll()
31+
sortWithNaturalOrdering()
32+
sortWithComparator()
33+
}
34+
35+
def runCollectionTest(test: CollectionTest) = {
36+
import test._
37+
testWithString()
38+
testWithInt()
39+
testWithDouble()
40+
testWithCustomClass()
41+
removeString()
42+
removeDoubleCornerCases()
43+
clear()
44+
containsString()
45+
containsDoubleCornerCases()
46+
iteratorString()
47+
toArrayObject()
48+
toArraySpecific()
49+
removeIf()
50+
// TODO: float to string
51+
// toStringCollectionDoubleEmpty()
52+
// toStringCollectionDoubleOneElement()
53+
// toStringCollectionDoubleHasCommaSpace()
54+
toStringCollectionAnyWithNull()
55+
toStringCollectionCustomClass()
56+
}
57+
58+
def runIterableTest(test: IterableTest) = {
59+
import test._
60+
empty()
61+
simpleSum()
62+
iteratorThrowsNoSuchElementException()
63+
}
64+
}

examples/test-suite-wasi/src/main/scala/test-suites-wasi/JavalibUtilTest.scala

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,24 @@ object JavalibUtilTest {
107107
// deepToString()
108108
}
109109

110+
locally {
111+
val test = new ArrayListTest
112+
AbstractTests.runListTests(test)
113+
AbstractTests.runCollectionTest(test)
114+
AbstractTests.runIterableTest(test)
115+
116+
import test._
117+
ensureCapacity()
118+
constructorInitialCapacity()
119+
constructorNullThrowsNullPointerException()
120+
testClone()
121+
removeRangeFromIdenticalIndices()
122+
removeRangeFromToInvalidIndices()
123+
removeRangeFromToFirstTwoElements()
124+
removeRangeFromToTwoElementsFromMiddle()
125+
removeRangeFromToLastTwoElementsAtTail()
126+
}
127+
110128
locally {
111129
val test = new ObjectsTest
112130
import test._

linker/shared/src/main/scala/org/scalajs/linker/backend/wasmemitter/CoreWasmLib.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,12 @@ final class CoreWasmLib(coreSpec: CoreSpec, globalInfo: LinkedGlobalInfo) {
596596
fb += LocalTee(doubleB)
597597
fb += F64Eq
598598
fb.ifThenElse(Int32) {
599-
fb += I32Const(1)
599+
// Object.is(+0.0, -0.0) -> false
600+
fb += LocalGet(doubleA)
601+
fb += I64ReinterpretF64
602+
fb += LocalGet(doubleB)
603+
fb += I64ReinterpretF64
604+
fb += I64Eq
600605
} {
601606
// both of a and b are NaN -> true
602607
// because JS Object.is(NaN, NaN) -> true

0 commit comments

Comments
 (0)
0