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 | 40 |
1 files changed, 40 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 000000000..952b1e545 --- /dev/null +++ b/js/src/jit-test/tests/self-test/readlineBuf.js @@ -0,0 +1,40 @@ +load(libdir + "asserts.js"); + +assertThrowsInstanceOf(function () { readlineBuf() }, Error); + +var testBuffers = [ + "foo\nbar\nbaz\n", + "foo\nbar\nbaz", + "foo\n\nbar\nbaz", + "f", + "\n", + "\nf", + "" +]; + +var expected = [ + [ "foo", "bar", "baz" ], + [ "foo", "bar", "baz" ], + [ "foo", "", "bar", "baz" ], + [ "f" ], + [ "" ], + [ "", "f" ], + [] +]; + +for (var idx in testBuffers) { + readlineBuf(testBuffers[idx]); + 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]); |