File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -1101,6 +1101,33 @@ test "debug upvalues" {
1101
1101
try expect ((try lua .upvalueId (-2 , 1 )) == try lua .upvalueId (-1 , 1 ));
1102
1102
}
1103
1103
1104
+ test "getstack" {
1105
+ var lua = try Lua .init (testing .allocator );
1106
+ defer lua .deinit ();
1107
+
1108
+ try expectError (Error .Fail , lua .getStack (1 ));
1109
+
1110
+ const function = struct {
1111
+ fn inner (l : * Lua ) i32 {
1112
+ // get info about calling lua function
1113
+ var info = l .getStack (1 ) catch unreachable ;
1114
+ l .getInfo (.{ .n = true }, & info );
1115
+ expectEqualStrings ("g" , info .name .? ) catch unreachable ;
1116
+ return 0 ;
1117
+ }
1118
+ }.inner ;
1119
+
1120
+ lua .pushFunction (ziglua .wrap (function ));
1121
+ lua .setGlobal ("f" );
1122
+
1123
+ try lua .doString (
1124
+ \\g = function()
1125
+ \\ f()
1126
+ \\end
1127
+ \\g()
1128
+ );
1129
+ }
1130
+
1104
1131
test "refs" {
1105
1132
// temporary test that includes a reference to all functions so
1106
1133
// they will be type-checked
You can’t perform that action at this time.
0 commit comments