Skip to content

Instantly share code, notes, and snippets.

@jonas
Last active August 29, 2015 13:56
Show Gist options
  • Save jonas/8993650 to your computer and use it in GitHub Desktop.
Save jonas/8993650 to your computer and use it in GitHub Desktop.
Test and output for debugging scala-js/scala-js#268
//...
it("should support Buffer !! - #268") {
val a = scala.collection.mutable.Buffer.empty[Int]
for (i <- 0 to 10) {
val p : Int = a.length / 2
expect(s"${a.length} / 2 -> $p, $i").toEqual("...")
a.insert(p, i)
expect(a.mkString(", ")).toEqual("...")
}
expect(a.mkString(", ")).toEqual("1, 3, 5, 7, 9, 10, 8, 6, 4, 2, 0")
}
it("should support Buffer - #268") {
val a = scala.collection.mutable.Buffer.empty[Int]
a.insert(0, 0)
a.remove(0)
for (i <- 0 to 10) {
a.insert(a.length / 2, i)
}
expect(a.mkString(", ")).toEqual("1, 3, 5, 7, 9, 10, 8, 6, 4, 2, 0")
}
//...
ScalaJS.c.java_lang_System$.prototype.arraycopy__O__I__O__I__I__V = (function(src, srcPos, dest, destPos, length) {
var jsSrc = ScalaJS.modules.java_lang_reflect_Array().getUnderlying__O__Lscala_scalajs_js_Array(src);
var jsDest = ScalaJS.modules.java_lang_reflect_Array().getUnderlying__O__Lscala_scalajs_js_Array(dest);
console.log("System.arraycopy(src=" + jsSrc + ", srcPos=" + srcPos + ", dest=" + jsDest + ", destPost=" + destPos + ", length=" + length + ") ??? " + (jsSrc === jsDest));
var i = 0;
while ((i < length)) {
jsDest[(destPos + i)] = jsSrc[(srcPos + i)];
i = (i + 1)
}
});
[info] --------------------
[info] insert(0, WrappedArray(0))
[info] seq.toList: List(0)
[info] seq.toList.length: 1
[info] this.size: (BEFORE) 0
[info] this.array (BEFORE copy__I) ,,,,,,,,,,,,,,, ??? 0
[info] System.arraycopy(src=,,,,,,,,,,,,,,,, srcPos=0, dest=,,,,,,,,,,,,,,,, destPost=1, length=0) ??? true
[info] this.array (BEFORE copyToA) ,,,,,,,,,,,,,,,
[info] this.array (BEFORE size= ) 0,,,,,,,,,,,,,,,
[info] this.size: (AFTER) 1
[info] --------------------
[info] insert(0, WrappedArray(1))
[info] seq.toList: List(1)
[info] seq.toList.length: 1
[info] this.size: (BEFORE) 1
[info] this.array (BEFORE copy__I) 0,,,,,,,,,,,,,,, ??? 1
[info] System.arraycopy(src=0,,,,,,,,,,,,,,,, srcPos=0, dest=0,,,,,,,,,,,,,,,, destPost=1, length=1) ??? true
[info] this.array (BEFORE copyToA) 0,0,,,,,,,,,,,,,,
[info] this.array (BEFORE size= ) 1,0,,,,,,,,,,,,,,
[info] this.size: (AFTER) 2
[info] --------------------
[info] insert(1, WrappedArray(2))
[info] seq.toList: List(2)
[info] seq.toList.length: 1
[info] this.size: (BEFORE) 2
[info] this.array (BEFORE copy__I) 1,0,,,,,,,,,,,,,, ??? 1
[info] System.arraycopy(src=1,0,,,,,,,,,,,,,,, srcPos=1, dest=1,0,,,,,,,,,,,,,,, destPost=2, length=1) ??? true
[info] this.array (BEFORE copyToA) 1,0,0,,,,,,,,,,,,,
[info] this.array (BEFORE size= ) 1,2,0,,,,,,,,,,,,,
[info] this.size: (AFTER) 3
[info] --------------------
[info] insert(1, WrappedArray(3))
[info] seq.toList: List(3)
[info] seq.toList.length: 1
[info] this.size: (BEFORE) 3
[info] this.array (BEFORE copy__I) 1,2,0,,,,,,,,,,,,, ??? 2
[info] System.arraycopy(src=1,2,0,,,,,,,,,,,,,, srcPos=1, dest=1,2,0,,,,,,,,,,,,,, destPost=2, length=2) ??? true
[info] this.array (BEFORE copyToA) 1,2,2,2,,,,,,,,,,,,
[info] this.array (BEFORE size= ) 1,3,2,2,,,,,,,,,,,,
[info] this.size: (AFTER) 4
[info] --------------------
[info] insert(2, WrappedArray(4))
[info] seq.toList: List(4)
[info] seq.toList.length: 1
[info] this.size: (BEFORE) 4
[info] this.array (BEFORE copy__I) 1,3,2,2,,,,,,,,,,,, ??? 2
[info] System.arraycopy(src=1,3,2,2,,,,,,,,,,,,, srcPos=2, dest=1,3,2,2,,,,,,,,,,,,, destPost=3, length=2) ??? true
[info] this.array (BEFORE copyToA) 1,3,2,2,2,,,,,,,,,,,
[info] this.array (BEFORE size= ) 1,3,4,2,2,,,,,,,,,,,
[info] this.size: (AFTER) 5
[info] --------------------
[info] insert(2, WrappedArray(5))
[info] seq.toList: List(5)
[info] seq.toList.length: 1
[info] this.size: (BEFORE) 5
[info] this.array (BEFORE copy__I) 1,3,4,2,2,,,,,,,,,,, ??? 3
[info] System.arraycopy(src=1,3,4,2,2,,,,,,,,,,,, srcPos=2, dest=1,3,4,2,2,,,,,,,,,,,, destPost=3, length=3) ??? true
[info] this.array (BEFORE copyToA) 1,3,4,4,4,4,,,,,,,,,,
[info] this.array (BEFORE size= ) 1,3,5,4,4,4,,,,,,,,,,
[info] this.size: (AFTER) 6
[info] --------------------
[info] insert(3, WrappedArray(6))
[info] seq.toList: List(6)
[info] seq.toList.length: 1
[info] this.size: (BEFORE) 6
[info] this.array (BEFORE copy__I) 1,3,5,4,4,4,,,,,,,,,, ??? 3
[info] System.arraycopy(src=1,3,5,4,4,4,,,,,,,,,,, srcPos=3, dest=1,3,5,4,4,4,,,,,,,,,,, destPost=4, length=3) ??? true
[info] this.array (BEFORE copyToA) 1,3,5,4,4,4,4,,,,,,,,,
[info] this.array (BEFORE size= ) 1,3,5,6,4,4,4,,,,,,,,,
[info] this.size: (AFTER) 7
[info] --------------------
[info] insert(3, WrappedArray(7))
[info] seq.toList: List(7)
[info] seq.toList.length: 1
[info] this.size: (BEFORE) 7
[info] this.array (BEFORE copy__I) 1,3,5,6,4,4,4,,,,,,,,, ??? 4
[info] System.arraycopy(src=1,3,5,6,4,4,4,,,,,,,,,, srcPos=3, dest=1,3,5,6,4,4,4,,,,,,,,,, destPost=4, length=4) ??? true
[info] this.array (BEFORE copyToA) 1,3,5,6,6,6,6,6,,,,,,,,
[info] this.array (BEFORE size= ) 1,3,5,7,6,6,6,6,,,,,,,,
[info] this.size: (AFTER) 8
[info] --------------------
[info] insert(4, WrappedArray(8))
[info] seq.toList: List(8)
[info] seq.toList.length: 1
[info] this.size: (BEFORE) 8
[info] this.array (BEFORE copy__I) 1,3,5,7,6,6,6,6,,,,,,,, ??? 4
[info] System.arraycopy(src=1,3,5,7,6,6,6,6,,,,,,,,, srcPos=4, dest=1,3,5,7,6,6,6,6,,,,,,,,, destPost=5, length=4) ??? true
[info] this.array (BEFORE copyToA) 1,3,5,7,6,6,6,6,6,,,,,,,
[info] this.array (BEFORE size= ) 1,3,5,7,8,6,6,6,6,,,,,,,
[info] this.size: (AFTER) 9
[info] --------------------
[info] insert(4, WrappedArray(9))
[info] seq.toList: List(9)
[info] seq.toList.length: 1
[info] this.size: (BEFORE) 9
[info] this.array (BEFORE copy__I) 1,3,5,7,8,6,6,6,6,,,,,,, ??? 5
[info] System.arraycopy(src=1,3,5,7,8,6,6,6,6,,,,,,,, srcPos=4, dest=1,3,5,7,8,6,6,6,6,,,,,,,, destPost=5, length=5) ??? true
[info] this.array (BEFORE copyToA) 1,3,5,7,8,8,8,8,8,8,,,,,,
[info] this.array (BEFORE size= ) 1,3,5,7,9,8,8,8,8,8,,,,,,
[info] this.size: (AFTER) 10
[info] --------------------
[info] insert(5, WrappedArray(10))
[info] seq.toList: List(10)
[info] seq.toList.length: 1
[info] this.size: (BEFORE) 10
[info] this.array (BEFORE copy__I) 1,3,5,7,9,8,8,8,8,8,,,,,, ??? 5
[info] System.arraycopy(src=1,3,5,7,9,8,8,8,8,8,,,,,,, srcPos=5, dest=1,3,5,7,9,8,8,8,8,8,,,,,,, destPost=6, length=5) ??? true
[info] this.array (BEFORE copyToA) 1,3,5,7,9,8,8,8,8,8,8,,,,,
[info] this.array (BEFORE size= ) 1,3,5,7,9,10,8,8,8,8,8,,,,,
[info] this.size: (AFTER) 11
[info] --------------------
[info] insert(0, WrappedArray(0))
[info] seq.toList: List(0)
[info] seq.toList.length: 1
[info] this.size: (BEFORE) 0
[info] this.array (BEFORE copy__I) ,,,,,,,,,,,,,,, ??? 0
[info] System.arraycopy(src=,,,,,,,,,,,,,,,, srcPos=0, dest=,,,,,,,,,,,,,,,, destPost=1, length=0) ??? true
[info] this.array (BEFORE copyToA) ,,,,,,,,,,,,,,,
[info] this.array (BEFORE size= ) 0,,,,,,,,,,,,,,,
[info] this.size: (AFTER) 1
[info] System.arraycopy(src=0,,,,,,,,,,,,,,,, srcPos=1, dest=0,,,,,,,,,,,,,,,, destPost=0, length=0) ??? true
[info] --------------------
[info] insert(0, WrappedArray(0))
[info] seq.toList: List(0)
[info] seq.toList.length: 1
[info] this.size: (BEFORE) 0
[info] this.array (BEFORE copy__I) ,,,,,,,,,,,,,,, ??? 0
[info] System.arraycopy(src=,,,,,,,,,,,,,,,, srcPos=0, dest=,,,,,,,,,,,,,,,, destPost=1, length=0) ??? true
[info] this.array (BEFORE copyToA) ,,,,,,,,,,,,,,,
[info] this.array (BEFORE size= ) 0,,,,,,,,,,,,,,,
[info] this.size: (AFTER) 1
[info] --------------------
[info] insert(0, WrappedArray(1))
[info] seq.toList: List(1)
[info] seq.toList.length: 1
[info] this.size: (BEFORE) 1
[info] this.array (BEFORE copy__I) 0,,,,,,,,,,,,,,, ??? 1
[info] System.arraycopy(src=0,,,,,,,,,,,,,,,, srcPos=0, dest=0,,,,,,,,,,,,,,,, destPost=1, length=1) ??? true
[info] this.array (BEFORE copyToA) 0,0,,,,,,,,,,,,,,
[info] this.array (BEFORE size= ) 1,0,,,,,,,,,,,,,,
[info] this.size: (AFTER) 2
[info] --------------------
[info] insert(1, WrappedArray(2))
[info] seq.toList: List(2)
[info] seq.toList.length: 1
[info] this.size: (BEFORE) 2
[info] this.array (BEFORE copy__I) 1,0,,,,,,,,,,,,,, ??? 1
[info] System.arraycopy(src=1,0,,,,,,,,,,,,,,, srcPos=1, dest=1,0,,,,,,,,,,,,,,, destPost=2, length=1) ??? true
[info] this.array (BEFORE copyToA) 1,0,0,,,,,,,,,,,,,
[info] this.array (BEFORE size= ) 1,2,0,,,,,,,,,,,,,
[info] this.size: (AFTER) 3
[info] --------------------
[info] insert(1, WrappedArray(3))
[info] seq.toList: List(3)
[info] seq.toList.length: 1
[info] this.size: (BEFORE) 3
[info] this.array (BEFORE copy__I) 1,2,0,,,,,,,,,,,,, ??? 2
[info] System.arraycopy(src=1,2,0,,,,,,,,,,,,,, srcPos=1, dest=1,2,0,,,,,,,,,,,,,, destPost=2, length=2) ??? true
[info] this.array (BEFORE copyToA) 1,2,2,2,,,,,,,,,,,,
[info] this.array (BEFORE size= ) 1,3,2,2,,,,,,,,,,,,
[info] this.size: (AFTER) 4
[info] --------------------
[info] insert(2, WrappedArray(4))
[info] seq.toList: List(4)
[info] seq.toList.length: 1
[info] this.size: (BEFORE) 4
[info] this.array (BEFORE copy__I) 1,3,2,2,,,,,,,,,,,, ??? 2
[info] System.arraycopy(src=1,3,2,2,,,,,,,,,,,,, srcPos=2, dest=1,3,2,2,,,,,,,,,,,,, destPost=3, length=2) ??? true
[info] this.array (BEFORE copyToA) 1,3,2,2,2,,,,,,,,,,,
[info] this.array (BEFORE size= ) 1,3,4,2,2,,,,,,,,,,,
[info] this.size: (AFTER) 5
[info] --------------------
[info] insert(2, WrappedArray(5))
[info] seq.toList: List(5)
[info] seq.toList.length: 1
[info] this.size: (BEFORE) 5
[info] this.array (BEFORE copy__I) 1,3,4,2,2,,,,,,,,,,, ??? 3
[info] System.arraycopy(src=1,3,4,2,2,,,,,,,,,,,, srcPos=2, dest=1,3,4,2,2,,,,,,,,,,,, destPost=3, length=3) ??? true
[info] this.array (BEFORE copyToA) 1,3,4,4,4,4,,,,,,,,,,
[info] this.array (BEFORE size= ) 1,3,5,4,4,4,,,,,,,,,,
[info] this.size: (AFTER) 6
[info] --------------------
[info] insert(3, WrappedArray(6))
[info] seq.toList: List(6)
[info] seq.toList.length: 1
[info] this.size: (BEFORE) 6
[info] this.array (BEFORE copy__I) 1,3,5,4,4,4,,,,,,,,,, ??? 3
[info] System.arraycopy(src=1,3,5,4,4,4,,,,,,,,,,, srcPos=3, dest=1,3,5,4,4,4,,,,,,,,,,, destPost=4, length=3) ??? true
[info] this.array (BEFORE copyToA) 1,3,5,4,4,4,4,,,,,,,,,
[info] this.array (BEFORE size= ) 1,3,5,6,4,4,4,,,,,,,,,
[info] this.size: (AFTER) 7
[info] --------------------
[info] insert(3, WrappedArray(7))
[info] seq.toList: List(7)
[info] seq.toList.length: 1
[info] this.size: (BEFORE) 7
[info] this.array (BEFORE copy__I) 1,3,5,6,4,4,4,,,,,,,,, ??? 4
[info] System.arraycopy(src=1,3,5,6,4,4,4,,,,,,,,,, srcPos=3, dest=1,3,5,6,4,4,4,,,,,,,,,, destPost=4, length=4) ??? true
[info] this.array (BEFORE copyToA) 1,3,5,6,6,6,6,6,,,,,,,,
[info] this.array (BEFORE size= ) 1,3,5,7,6,6,6,6,,,,,,,,
[info] this.size: (AFTER) 8
[info] --------------------
[info] insert(4, WrappedArray(8))
[info] seq.toList: List(8)
[info] seq.toList.length: 1
[info] this.size: (BEFORE) 8
[info] this.array (BEFORE copy__I) 1,3,5,7,6,6,6,6,,,,,,,, ??? 4
[info] System.arraycopy(src=1,3,5,7,6,6,6,6,,,,,,,,, srcPos=4, dest=1,3,5,7,6,6,6,6,,,,,,,,, destPost=5, length=4) ??? true
[info] this.array (BEFORE copyToA) 1,3,5,7,6,6,6,6,6,,,,,,,
[info] this.array (BEFORE size= ) 1,3,5,7,8,6,6,6,6,,,,,,,
[info] this.size: (AFTER) 9
[info] --------------------
[info] insert(4, WrappedArray(9))
[info] seq.toList: List(9)
[info] seq.toList.length: 1
[info] this.size: (BEFORE) 9
[info] this.array (BEFORE copy__I) 1,3,5,7,8,6,6,6,6,,,,,,, ??? 5
[info] System.arraycopy(src=1,3,5,7,8,6,6,6,6,,,,,,,, srcPos=4, dest=1,3,5,7,8,6,6,6,6,,,,,,,, destPost=5, length=5) ??? true
[info] this.array (BEFORE copyToA) 1,3,5,7,8,8,8,8,8,8,,,,,,
[info] this.array (BEFORE size= ) 1,3,5,7,9,8,8,8,8,8,,,,,,
[info] this.size: (AFTER) 10
[info] --------------------
[info] insert(5, WrappedArray(10))
[info] seq.toList: List(10)
[info] seq.toList.length: 1
[info] this.size: (BEFORE) 10
[info] this.array (BEFORE copy__I) 1,3,5,7,9,8,8,8,8,8,,,,,, ??? 5
[info] System.arraycopy(src=1,3,5,7,9,8,8,8,8,8,,,,,,, srcPos=5, dest=1,3,5,7,9,8,8,8,8,8,,,,,,, destPost=6, length=5) ??? true
[info] this.array (BEFORE copyToA) 1,3,5,7,9,8,8,8,8,8,8,,,,,
[info] this.array (BEFORE size= ) 1,3,5,7,9,10,8,8,8,8,8,,,,,
[info] this.size: (AFTER) 11
[info]
[info] Scala.js compiler regression tests
[info] + Wrong division conversion (7 / 2.0) - #18
[info] + js.String + js.String is ambiguous - #20
[info] + Abort with some pattern match guards - #22
[info] + Bad encoding for characters spanning 2 UTF-16 chars - #23
[info] + String concatenation with null - #26
[info] + should emit static calls when forwarding to another constructor - #66
[info] + should not swallow Unit expressions when converting to js.Undefined - #83
[info] + should correctly call subSequence on non-string CharSequences - #55
[info] + should correctly concat primitive values to strings - #113
[info] + should resolve overloads on scala.Function.apply when converting to js.Function - #125
[info] + should correctly dispatch calls on private functions - #165
[info] + should correctly mangle JavaScript reserved identifiers - #153
[info] + should correctly mangle identifiers starting with a digit - #153
[info] + should support class literals for existential value types - #218
[error] x should support Buffer !! - #268
[error] Expected '0 / 2 -> 0, 0' to equal '...'.
[error] Expected '0' to equal '...'.
[error] Expected '1 / 2 -> 0, 1' to equal '...'.
[error] Expected '1, 0' to equal '...'.
[error] Expected '2 / 2 -> 1, 2' to equal '...'.
[error] Expected '1, 2, 0' to equal '...'.
[error] Expected '3 / 2 -> 1, 3' to equal '...'.
[error] Expected '1, 3, 2, 2' to equal '...'.
[error] Expected '4 / 2 -> 2, 4' to equal '...'.
[error] Expected '1, 3, 4, 2, 2' to equal '...'.
[error] Expected '5 / 2 -> 2, 5' to equal '...'.
[error] Expected '1, 3, 5, 4, 4, 4' to equal '...'.
[error] Expected '6 / 2 -> 3, 6' to equal '...'.
[error] Expected '1, 3, 5, 6, 4, 4, 4' to equal '...'.
[error] Expected '7 / 2 -> 3, 7' to equal '...'.
[error] Expected '1, 3, 5, 7, 6, 6, 6, 6' to equal '...'.
[error] Expected '8 / 2 -> 4, 8' to equal '...'.
[error] Expected '1, 3, 5, 7, 8, 6, 6, 6, 6' to equal '...'.
[error] Expected '9 / 2 -> 4, 9' to equal '...'.
[error] Expected '1, 3, 5, 7, 9, 8, 8, 8, 8, 8' to equal '...'.
[error] Expected '10 / 2 -> 5, 10' to equal '...'.
[error] Expected '1, 3, 5, 7, 9, 10, 8, 8, 8, 8, 8' to equal '...'.
[error] Expected '1, 3, 5, 7, 9, 10, 8, 8, 8, 8, 8' to equal '1, 3, 5, 7, 9, 10, 8, 6, 4, 2, 0'.
[error] x should support Buffer - #268
[error] Expected '1, 3, 5, 7, 9, 10, 8, 8, 8, 8, 8' to equal '1, 3, 5, 7, 9, 10, 8, 6, 4, 2, 0'.
ScalaJS.c.scala_collection_mutable_ArrayBuffer.prototype.insertAll__I__Lscala_collection_Traversable__V = (function(n, seq) {
if (((n < 0) || (n > this.size0__I()))) {
throw new ScalaJS.c.java_lang_IndexOutOfBoundsException().init___T(ScalaJS.objectToString(ScalaJS.bI(n)))
};
console.log("--------------------");
console.log("insert(" + n + ", " + seq + ")");
var xs = seq.toList__Lscala_collection_immutable_List();
console.log("seq.toList: " + xs);
var len = xs.length__I();
console.log("seq.toList.length: " + len);
console.log("this.size: (BEFORE) " + this.size0__I());
this.ensureSize__I__V((this.size0__I() + len));
console.log("this.array (BEFORE copy__I) " + this.array__AO().underlying + " ??? " + (this.size0__I() - n));
this.copy__I__I__I__V(n, (n + len), (this.size0__I() - n));
console.log("this.array (BEFORE copyToA) " + this.array__AO().underlying);
xs.copyToArray__O__I__V(this.array__AO(), n);
console.log("this.array (BEFORE size= ) " + this.array__AO().underlying);
this.size0_$eq__I__V((this.size0__I() + len))
console.log("this.size: (AFTER) " + this.size0__I());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment