diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2024-09-08 19:03:54 +0200 |
|---|---|---|
| committer | Randy Palamar <randy@rnpnr.xyz> | 2024-09-13 06:04:17 -0600 |
| commit | c8694ee0f0fb0540bf0d4e7a25f65924eda02caf (patch) | |
| tree | 69fc44640adc4a6c05a7603774f0b5cfed75c5cb /test | |
| parent | 06453ed994acbaa48a590fa71d4dfb18e1ff3a64 (diff) | |
| download | vis-c8694ee0f0fb0540bf0d4e7a25f65924eda02caf.tar.gz vis-c8694ee0f0fb0540bf0d4e7a25f65924eda02caf.tar.xz | |
lua: add tests for the different vis.pipe argument variants
Diffstat (limited to 'test')
| -rw-r--r-- | test/lua/pipe.in | 1 | ||||
| -rw-r--r-- | test/lua/pipe.lua | 86 |
2 files changed, 87 insertions, 0 deletions
diff --git a/test/lua/pipe.in b/test/lua/pipe.in new file mode 100644 index 0000000..1910281 --- /dev/null +++ b/test/lua/pipe.in @@ -0,0 +1 @@ +foo
\ No newline at end of file diff --git a/test/lua/pipe.lua b/test/lua/pipe.lua new file mode 100644 index 0000000..9dfb670 --- /dev/null +++ b/test/lua/pipe.lua @@ -0,0 +1,86 @@ +require 'busted.runner'() + +local file = vis.win.file + +describe("vis.pipe", function() + + local FULLSCREEN = true + + it("vis.pipe no input", function() + vis:pipe("cat > f") + local f = io.open("f", "r") + assert.truthy(f) + assert.are.equal("", f:read("*a")) + f:close() + os.remove("f") + end) + + it("vis.pipe no input fullscreen", function() + vis:pipe("cat > f", FULLSCREEN) + local f = io.open("f", "r") + assert.truthy(f) + assert.are.equal("", f:read("*a")) + f:close() + os.remove("f") + end) + + it("vis.pipe buffer", function() + vis:pipe("foo", "cat > f") + local f = io.open("f", "r") + assert.truthy(f) + assert.are.equal(f:read("*a"), "foo") + f:close() + os.remove("f") + end) + + it("vis.pipe buffer fullscreen", function() + vis:pipe("foo", "cat > f", FULLSCREEN) + local f = io.open("f", "r") + assert.truthy(f) + assert.are.equal(f:read("*a"), "foo") + f:close() + os.remove("f") + end) + + it("vis.pipe range", function() + vis:pipe(file, {start=0, finish=3}, "cat > f") + local f = io.open("f", "r") + assert.truthy(f) + assert.are.equal(f:read("*a"), "foo") + f:close() + os.remove("f") + end) + + it("vis.pipe range fullscreen", function() + vis:pipe(file, {start=0, finish=3}, "cat > f", FULLSCREEN) + local f = io.open("f", "r") + assert.truthy(f) + assert.are.equal(f:read("*a"), "foo") + f:close() + os.remove("f") + end) + + it("vis.pipe explicit nil text", function() + assert.has_error(function() vis:pipe(nil, "true") end) + end) + + it("vis.pipe explicit nil text fullscreen", function() + assert.has_error(function() vis:pipe(nil, "true", FULLSCREEN) end) + end) + + it("vis.pipe explicit nil file", function() + assert.has_error(function() vis:pipe(nil, {start=0, finish=0}, "true") end) + end) + + it("vis.pipe explicit nil file fullscreen", function() + assert.has_error(function() vis:pipe(nil, {start=0, finish=0}, "true", FULLSCREEN) end) + end) + + it("vis.pipe wrong argument order file, range, cmd", function() + assert.has_error(function() vis:pipe({start=0, finish=0}, vis.win.file, "true") end) + end) + + it("vis.pipe wrong argument order fullscreen, cmd", function() + assert.has_error(function() vis:pipe(FULLSCREEN, "true") end) + end) +end) |
