aboutsummaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/04-term_spec.lua41
1 files changed, 39 insertions, 2 deletions
diff --git a/spec/04-term_spec.lua b/spec/04-term_spec.lua
index b3de461..0ce0033 100644
--- a/spec/04-term_spec.lua
+++ b/spec/04-term_spec.lua
@@ -928,10 +928,31 @@ describe("Terminal:", function()
928 end) 928 end)
929 929
930 930
931 it("reads ANSI escape sequences, just an '<esc>O' (<alt><O> key press)", function()
932 setbuffer("\27O")
933 assert.are.same({"\27O", "ansi"}, {system.readansi(0)})
934 end)
935
936
937 it("reads <alt>+key key presses; <esc>+<key>", function()
938 setbuffer("\27a\27b\27c\27d")
939 assert.are.same({"\27a", "ansi"}, {system.readansi(0)})
940 assert.are.same({"\27b", "ansi"}, {system.readansi(0)})
941 assert.are.same({"\27c", "ansi"}, {system.readansi(0)})
942 assert.are.same({"\27d", "ansi"}, {system.readansi(0)})
943 end)
944
945
946 it("reads <ctrl><alt>[ key press; <esc>+<esc>", function()
947 setbuffer("\27\27\27\27")
948 assert.are.same({"\27\27", "ansi"}, {system.readansi(0)})
949 assert.are.same({"\27\27", "ansi"}, {system.readansi(0)})
950 end)
951
952
931 it("returns a single <esc> character if no sequence is found", function() 953 it("returns a single <esc> character if no sequence is found", function()
932 setbuffer("\27\27[A") 954 setbuffer("\27")
933 assert.are.same({"\27", "char"}, {system.readansi(0)}) 955 assert.are.same({"\27", "char"}, {system.readansi(0)})
934 assert.are.same({"\27[A", "ansi"}, {system.readansi(0)})
935 end) 956 end)
936 957
937 958
@@ -945,6 +966,22 @@ describe("Terminal:", function()
945 assert.is.near(1, timing, 0.5) -- this also works for MacOS in CI 966 assert.is.near(1, timing, 0.5) -- this also works for MacOS in CI
946 end) 967 end)
947 968
969
970 it("incomplete ANSI sequences will be completed on next call", function()
971 setbuffer("\27[")
972 assert.are.same({nil, "timeout", "\27["}, {system.readansi(0)})
973 setbuffer("A")
974 assert.are.same({"\27[A", "ansi"}, {system.readansi(0)})
975 end)
976
977
978 it("incomplete UTF8 sequences will be completed on next call", function()
979 setbuffer(string.char(240, 159))
980 assert.are.same({nil, "timeout", string.char(240, 159)}, {system.readansi(0)})
981 setbuffer(string.char(154, 128))
982 assert.are.same({"🚀", "char"}, {system.readansi(0)})
983 end)
984
948 end) 985 end)
949 986
950 end) 987 end)