Skip to content

Commit

Permalink
Error handlers can now yield
Browse files Browse the repository at this point in the history
  • Loading branch information
MCJack123 committed Jan 1, 2024
1 parent 9193f14 commit a56bb60
Showing 1 changed file with 0 additions and 85 deletions.
85 changes: 0 additions & 85 deletions resources/CCT-Tests.patch
Original file line number Diff line number Diff line change
Expand Up @@ -57,88 +57,3 @@ diff -ruN --strip -x .DS_Store projects/core/src/test/resources/test-rom/spec/lu
- end)
- end)
end)
diff -ruN --strip -x .DS_Store projects/core/src/test/resources/test-rom/spec/lua/coroutine_spec.lua b/projects/core/src/test/resources/test-rom/spec/lua/coroutine_spec.lua
--- a/projects/core/src/test/resources/test-rom/spec/lua/coroutine_spec.lua 2021-06-08 23:55:10.000000000 -0400
+++ b/projects/core/src/test/resources/test-rom/spec/lua/coroutine_spec.lua 2021-04-28 03:19:00.000000000 -0400
@@ -35,20 +35,18 @@
debug.sethook(function(kind)
counts[kind] = (counts[kind] or 0) + 1
expect(coroutine.yield(kind)):eq(kind)
- end, "crl", 1)
+ end, "l", 1)

expect(string.gsub("xyz", "x", "z")):eq("zyz")
expect(pcall(function()
local x = 0
for i = 1, 5 do x = x + i end
end)):eq(true)

debug.sethook(nil)

-- These numbers are going to vary beyond the different VMs a
-- little. As long as they're non-0, it's all fine.
- expect(counts.call):ne(0)
- expect(counts['return']):ne(0)
expect(counts.count):ne(0)
expect(counts.line):ne(0)
end)
@@ -195,59 +169,6 @@
expect("Error message!"):eq(msg)
end)
end)
-
- it("with an error in the error handler", function()
- coroutine_echo(function()
- local ok, msg = xpcall(function()
- local a, b, c = coroutine.yield(1, 2, 3)
- expect(1):eq(a)
- expect(2):eq(b)
- expect(3):eq(c)
-
- error("Error message")
- end, function(msg) error(msg) end)
-
- expect(false):eq(ok)
- expect("error in error handling"):eq(msg)
- end)
- end)
-
- it("within the error handler", function()
- coroutine_echo(function()
- local ok, msg = xpcall(function()
- local a, b, c = coroutine.yield(1, 2, 3)
- expect(1):eq(a)
- expect(2):eq(b)
- expect(3):eq(c)
-
- error("Error message", 0)
- end, function(msg)
- return coroutine.yield(msg) .. "!"
- end)
-
- expect(false):eq(ok)
- expect("Error message!"):eq(msg)
- end)
- end)
-
- it("within the error handler with an error", function()
- coroutine_echo(function()
- local ok, msg = xpcall(function()
- local a, b, c = coroutine.yield(1, 2, 3)
- expect(1):eq(a)
- expect(2):eq(b)
- expect(3):eq(c)
-
- error("Error message", 0)
- end, function(msg)
- coroutine.yield(msg)
- error("nope")
- end)
-
- expect(false):eq(ok)
- expect("error in error handling"):eq(msg)
- end)
- end)
end)

it("within metamethods", function()

0 comments on commit a56bb60

Please sign in to comment.