diff options
Diffstat (limited to 'js/src/jit-test/tests/self-test/readlineBuf.js')
-rw-r--r-- | js/src/jit-test/tests/self-test/readlineBuf.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/self-test/readlineBuf.js b/js/src/jit-test/tests/self-test/readlineBuf.js new file mode 100644 index 0000000000..1430c4ae49 --- /dev/null +++ b/js/src/jit-test/tests/self-test/readlineBuf.js @@ -0,0 +1,42 @@ +load(libdir + "asserts.js"); + +assertThrowsInstanceOf(function () { readlineBuf() }, Error); + +var testBuffers = [ + "foo\nbar\nbaz\n", + "foo\nbar\nbaz", + "foo\n\nbar\nbaz", + "f", + "\n", + "\nf", + "", + "Ää\n\u{10ffff}", +]; + +var expected = [ + [ "foo", "bar", "baz" ], + [ "foo", "bar", "baz" ], + [ "foo", "", "bar", "baz" ], + [ "f" ], + [ "" ], + [ "", "f" ], + [], + ["Ää", "\u{10ffff}"], +]; + +for (var [idx, testValue] of testBuffers.entries()) { + readlineBuf(testValue); + var result = []; + + while ((line = readlineBuf()) != null) { + result.push(line); + } + + assertDeepEq(result, expected[idx]); +} + +readlineBuf(testBuffers[0]); +readlineBuf(); +readlineBuf(); +readlineBuf(testBuffers[3]); +assertEq(readlineBuf(), expected[3][0]); |