File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -3660,6 +3660,25 @@ test "ref and unref in user table" {
36603660 try std .testing .expectEqual (0 , lua .lengthOf (1 ));
36613661}
36623662
3663+ test "ref should return nil" {
3664+ const lua = try Lua .init (std .testing .allocator );
3665+ defer lua .deinit ();
3666+
3667+ lua .newTable ();
3668+ lua .pushNil ();
3669+ const ref = lua .ref (1 );
3670+
3671+ try std .testing .expectEqual (1 , lua .getTop ());
3672+ try std .testing .expectEqual (Lua .Ref .Nil , ref );
3673+
3674+ const t = lua .getTableIndexRaw (1 , ref );
3675+ try std .testing .expectEqual (Lua .Type .nil , t );
3676+ try std .testing .expect (lua .isNil (-1 ));
3677+
3678+ lua .unref (1 , ref );
3679+ try std .testing .expectEqual (0 , lua .lengthOf (1 ));
3680+ }
3681+
36633682test "ref and unref in registry" {
36643683 const lua = try Lua .init (std .testing .allocator );
36653684 defer lua .deinit ();
You can’t perform that action at this time.
0 commit comments