diff options
author | 2023-09-13 19:49:43 -0700 | |
---|---|---|
committer | 2023-09-13 19:49:43 -0700 | |
commit | d37602f316daada630bbf9664c18878d11e30df4 (patch) | |
tree | 8fe2336d8e3610d7b3538a10219816c72213e445 /test/js | |
parent | cb52556bd1669d0b23e705d82284b673f8f1cd4c (diff) | |
download | bun-d37602f316daada630bbf9664c18878d11e30df4.tar.gz bun-d37602f316daada630bbf9664c18878d11e30df4.tar.zst bun-d37602f316daada630bbf9664c18878d11e30df4.zip |
fix(BunFile.slice) fix slice when length is greater than the size (#5186)
* check the limits for file, when slicing
* check eof
* undo test
Diffstat (limited to 'test/js')
-rw-r--r-- | test/js/bun/io/bun-write.test.js | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/test/js/bun/io/bun-write.test.js b/test/js/bun/io/bun-write.test.js index f435d2ceb..a05fa283a 100644 --- a/test/js/bun/io/bun-write.test.js +++ b/test/js/bun/io/bun-write.test.js @@ -300,6 +300,16 @@ it("offset should work #4963", async () => { expect(contents).toBe("ntents"); }); +it("length should be limited by file size #5080", async () => { + const filename = tmpdir() + "/bun.test.offset2.txt"; + await Bun.write(filename, "contents"); + const file = Bun.file(filename); + const slice = file.slice(2, 1024); + const contents = await slice.text(); + expect(contents).toBe("ntents"); + expect(contents.length).toBeLessThanOrEqual(file.size); +}); + it("#2674", async () => { const file = path.join(import.meta.dir, "big-stdout.js"); |