@@ -337,7 +337,7 @@ test "type of and getting values" {
337
337
_ = lua .pushFString ("%s %s %d" , .{ "hello" , "world" , @as (i32 , 10 ) });
338
338
try expectEqual (.string , lua .typeOf (-1 ));
339
339
try expect (lua .isString (-1 ));
340
- try expectEqualStrings ("hello world 10" , std . mem . span ( try lua .toString (-1 ) ));
340
+ try expectEqualStrings ("hello world 10" , try lua .toString (-1 ));
341
341
342
342
lua .pushValue (2 );
343
343
try expectEqual (.boolean , lua .typeOf (-1 ));
@@ -564,7 +564,7 @@ test "string buffers" {
564
564
lua .pushNumber (5.1 );
565
565
buffer .addValue ();
566
566
buffer .pushResult ();
567
- try expectEqualStrings ("ziglua api 5.1" , try lua .toBytes (-1 ));
567
+ try expectEqualStrings ("ziglua api 5.1" , try lua .toString (-1 ));
568
568
569
569
// now test a small buffer
570
570
buffer .init (lua );
@@ -578,7 +578,7 @@ test "string buffers" {
578
578
@memcpy (b [0.. 23], "defghijklmnopqrstuvwxyz" );
579
579
buffer .addSize (23 );
580
580
buffer .pushResult ();
581
- try expectEqualStrings ("abcdefghijklmnopqrstuvwxyz" , try lua .toBytes (-1 ));
581
+ try expectEqualStrings ("abcdefghijklmnopqrstuvwxyz" , try lua .toString (-1 ));
582
582
lua .pop (1 );
583
583
584
584
if (ziglua .lang == .lua51 or ziglua .lang == .luajit ) return ;
@@ -587,7 +587,7 @@ test "string buffers" {
587
587
b = buffer .prep ();
588
588
@memcpy (b [0.. 3], "abc" );
589
589
buffer .pushResultSize (3 );
590
- try expectEqualStrings ("abc" , try lua .toBytes (-1 ));
590
+ try expectEqualStrings ("abc" , try lua .toString (-1 ));
591
591
lua .pop (1 );
592
592
593
593
if (ziglua .lang == .luau ) return ;
@@ -758,9 +758,9 @@ test "concat" {
758
758
lua .concat (3 );
759
759
760
760
if (ziglua .lang == .lua53 or ziglua .lang == .lua54 ) {
761
- try expectEqualStrings ("hello 10.0 wow!" , try lua .toBytes (-1 ));
761
+ try expectEqualStrings ("hello 10.0 wow!" , try lua .toString (-1 ));
762
762
} else {
763
- try expectEqualStrings ("hello 10 wow!" , try lua .toBytes (-1 ));
763
+ try expectEqualStrings ("hello 10 wow!" , try lua .toString (-1 ));
764
764
}
765
765
}
766
766
@@ -821,18 +821,18 @@ test "table access" {
821
821
822
822
if (ziglua .lang == .lua53 or ziglua .lang == .lua54 ) {
823
823
try expectEqual (.string , lua .rawGetIndex (1 , 1 ));
824
- try expectEqualStrings ("first" , try lua .toBytes (-1 ));
824
+ try expectEqualStrings ("first" , try lua .toString (-1 ));
825
825
}
826
826
827
827
try expectEqual (.string , switch (ziglua .lang ) {
828
828
.lua53 , .lua54 = > lua .getIndex (1 , 1 ),
829
829
else = > lua .rawGetIndex (1 , 1 ),
830
830
});
831
- try expectEqualStrings ("first" , try lua .toBytes (-1 ));
831
+ try expectEqualStrings ("first" , try lua .toString (-1 ));
832
832
833
833
_ = lua .pushStringZ ("key" );
834
834
try expectEqual (.string , lua .getTable (1 ));
835
- try expectEqualStrings ("value" , try lua .toBytes (-1 ));
835
+ try expectEqualStrings ("value" , try lua .toString (-1 ));
836
836
837
837
_ = lua .pushStringZ ("other one" );
838
838
try expectEqual (.number , lua .rawGetTable (1 ));
@@ -1037,7 +1037,7 @@ test "userdata and uservalues" {
1037
1037
try expectEqual (.number , try lua .getUserValue (1 , 1 ));
1038
1038
try expectEqual (1234.56 , try lua .toNumber (-1 ));
1039
1039
try expectEqual (.string , try lua .getUserValue (1 , 2 ));
1040
- try expectEqualStrings ("test string" , try lua .toBytes (-1 ));
1040
+ try expectEqualStrings ("test string" , try lua .toString (-1 ));
1041
1041
1042
1042
try expectError (error .Fail , lua .setUserValue (1 , 3 ));
1043
1043
try expectError (error .Fail , lua .getUserValue (1 , 3 ));
@@ -1087,15 +1087,15 @@ test "table traversal" {
1087
1087
while (lua .next (1 )) {
1088
1088
switch (lua .typeOf (-1 )) {
1089
1089
.string = > {
1090
- try expectEqualStrings ("key" , try lua .toBytes (-2 ));
1091
- try expectEqualStrings ("value" , try lua .toBytes (-1 ));
1090
+ try expectEqualStrings ("key" , try lua .toString (-2 ));
1091
+ try expectEqualStrings ("value" , try lua .toString (-1 ));
1092
1092
},
1093
1093
.boolean = > {
1094
- try expectEqualStrings ("second" , try lua .toBytes (-2 ));
1094
+ try expectEqualStrings ("second" , try lua .toString (-2 ));
1095
1095
try expectEqual (true , lua .toBoolean (-1 ));
1096
1096
},
1097
1097
.number = > {
1098
- try expectEqualStrings ("third" , try lua .toBytes (-2 ));
1098
+ try expectEqualStrings ("third" , try lua .toString (-2 ));
1099
1099
try expectEqual (1 , try toInteger (& lua , -1 ));
1100
1100
},
1101
1101
else = > unreachable ,
@@ -1118,7 +1118,7 @@ test "registry" {
1118
1118
1119
1119
// get key from the registry
1120
1120
_ = lua .rawGetPtr (ziglua .registry_index , key );
1121
- try expectEqualStrings ("hello there" , try lua .toBytes (-1 ));
1121
+ try expectEqualStrings ("hello there" , try lua .toString (-1 ));
1122
1122
}
1123
1123
1124
1124
test "closing vars" {
@@ -1168,7 +1168,7 @@ test "raise error" {
1168
1168
1169
1169
lua .pushFunction (ziglua .wrap (makeError ));
1170
1170
try expectError (error .Runtime , lua .protectedCall (0 , 0 , 0 ));
1171
- try expectEqualStrings ("makeError made an error" , try lua .toBytes (-1 ));
1171
+ try expectEqualStrings ("makeError made an error" , try lua .toString (-1 ));
1172
1172
}
1173
1173
1174
1174
fn continuation (l : * Lua , status : ziglua.Status , ctx : isize ) i32 {
@@ -1226,7 +1226,7 @@ test "yielding" {
1226
1226
try expectEqual (.ok , try thread .resumeThread (lua , 0 ));
1227
1227
}
1228
1228
1229
- try expectEqualStrings ("done" , try thread .toBytes (-1 ));
1229
+ try expectEqualStrings ("done" , try thread .toString (-1 ));
1230
1230
}
1231
1231
1232
1232
fn continuation52 (l : * Lua ) i32 {
@@ -1266,7 +1266,7 @@ test "yielding Lua 5.2" {
1266
1266
lua .pop (lua .getTop ());
1267
1267
}
1268
1268
try expectEqual (.ok , try thread .resumeThread (lua , 0 ));
1269
- try expectEqualStrings ("done" , try thread .toBytes (-1 ));
1269
+ try expectEqualStrings ("done" , try thread .toString (-1 ));
1270
1270
}
1271
1271
1272
1272
test "yielding no continuation" {
@@ -1321,7 +1321,7 @@ test "resuming" {
1321
1321
lua .pop (lua .getTop ());
1322
1322
}
1323
1323
try expectEqual (.ok , if (ziglua .lang == .lua51 or ziglua .lang == .luajit ) try thread .resumeThread (0 ) else try thread .resumeThread (lua , 0 ));
1324
- try expectEqualStrings ("done" , try thread .toBytes (-1 ));
1324
+ try expectEqualStrings ("done" , try thread .toString (-1 ));
1325
1325
}
1326
1326
1327
1327
test "aux check functions" {
@@ -1343,22 +1343,22 @@ test "aux check functions" {
1343
1343
1344
1344
lua .pushFunction (function );
1345
1345
lua .protectedCall (0 , 0 , 0 ) catch {
1346
- try expectStringContains ("argument #1" , try lua .toBytes (-1 ));
1346
+ try expectStringContains ("argument #1" , try lua .toString (-1 ));
1347
1347
lua .pop (-1 );
1348
1348
};
1349
1349
1350
1350
lua .pushFunction (function );
1351
1351
lua .pushNil ();
1352
1352
lua .protectedCall (1 , 0 , 0 ) catch {
1353
- try expectStringContains ("number expected" , try lua .toBytes (-1 ));
1353
+ try expectStringContains ("number expected" , try lua .toString (-1 ));
1354
1354
lua .pop (-1 );
1355
1355
};
1356
1356
1357
1357
lua .pushFunction (function );
1358
1358
lua .pushNil ();
1359
1359
lua .pushInteger (3 );
1360
1360
lua .protectedCall (2 , 0 , 0 ) catch {
1361
- try expectStringContains ("string expected" , try lua .toBytes (-1 ));
1361
+ try expectStringContains ("string expected" , try lua .toString (-1 ));
1362
1362
lua .pop (-1 );
1363
1363
};
1364
1364
@@ -1367,7 +1367,7 @@ test "aux check functions" {
1367
1367
lua .pushInteger (3 );
1368
1368
_ = lua .pushString ("hello world" );
1369
1369
lua .protectedCall (3 , 0 , 0 ) catch {
1370
- try expectStringContains ("number expected" , try lua .toBytes (-1 ));
1370
+ try expectStringContains ("number expected" , try lua .toString (-1 ));
1371
1371
lua .pop (-1 );
1372
1372
};
1373
1373
@@ -1377,7 +1377,7 @@ test "aux check functions" {
1377
1377
_ = lua .pushString ("hello world" );
1378
1378
lua .pushNumber (4 );
1379
1379
lua .protectedCall (4 , 0 , 0 ) catch {
1380
- try expectStringContains ("string expected" , try lua .toBytes (-1 ));
1380
+ try expectStringContains ("string expected" , try lua .toString (-1 ));
1381
1381
lua .pop (-1 );
1382
1382
};
1383
1383
@@ -1388,7 +1388,7 @@ test "aux check functions" {
1388
1388
lua .pushNumber (4 );
1389
1389
_ = lua .pushStringZ ("hello world" );
1390
1390
lua .protectedCall (5 , 0 , 0 ) catch {
1391
- try expectStringContains ("boolean expected" , try lua .toBytes (-1 ));
1391
+ try expectStringContains ("boolean expected" , try lua .toString (-1 ));
1392
1392
lua .pop (-1 );
1393
1393
};
1394
1394
@@ -1401,7 +1401,7 @@ test "aux check functions" {
1401
1401
_ = lua .pushStringZ ("hello world" );
1402
1402
lua .pushBoolean (true );
1403
1403
lua .protectedCall (6 , 0 , 0 ) catch {
1404
- try expectEqualStrings ("bad argument #7 to '?' (number expected, got no value)" , try lua .toBytes (-1 ));
1404
+ try expectEqualStrings ("bad argument #7 to '?' (number expected, got no value)" , try lua .toString (-1 ));
1405
1405
lua .pop (-1 );
1406
1406
};
1407
1407
}
@@ -1495,7 +1495,7 @@ test "checkOption" {
1495
1495
lua .pushFunction (function );
1496
1496
_ = lua .pushStringZ ("unknown" );
1497
1497
try expectError (error .Runtime , lua .protectedCall (1 , 1 , 0 ));
1498
- try expectStringContains ("(invalid option 'unknown')" , try lua .toBytes (-1 ));
1498
+ try expectStringContains ("(invalid option 'unknown')" , try lua .toString (-1 ));
1499
1499
}
1500
1500
1501
1501
test "get global fail" {
@@ -1514,7 +1514,7 @@ test "globalSub" {
1514
1514
defer lua .deinit ();
1515
1515
1516
1516
_ = lua .globalSub ("-gity -!" , "-" , "zig" );
1517
- try expectEqualStrings ("ziggity zig!" , try lua .toBytes (-1 ));
1517
+ try expectEqualStrings ("ziggity zig!" , try lua .toString (-1 ));
1518
1518
}
1519
1519
1520
1520
test "loadBuffer" {
@@ -1552,7 +1552,7 @@ test "where" {
1552
1552
);
1553
1553
1554
1554
_ = try lua .getGlobal ("ret" );
1555
- try expectEqualStrings ("[string \" ...\" ]:2: " , try lua .toBytes (-1 ));
1555
+ try expectEqualStrings ("[string \" ...\" ]:2: " , try lua .toString (-1 ));
1556
1556
}
1557
1557
1558
1558
test "ref" {
@@ -1569,7 +1569,7 @@ test "ref" {
1569
1569
const ref = try lua .ref (ziglua .registry_index );
1570
1570
1571
1571
_ = lua .rawGetIndex (ziglua .registry_index , ref );
1572
- try expectEqualStrings ("Hello there" , try lua .toBytes (-1 ));
1572
+ try expectEqualStrings ("Hello there" , try lua .toString (-1 ));
1573
1573
1574
1574
lua .unref (ziglua .registry_index , ref );
1575
1575
}
@@ -1590,7 +1590,7 @@ test "ref luau" {
1590
1590
const ref = try lua .ref (2 );
1591
1591
1592
1592
_ = lua .rawGetIndex (ziglua .registry_index , ref );
1593
- try expectEqualStrings ("Hello there" , try lua .toBytes (-1 ));
1593
+ try expectEqualStrings ("Hello there" , try lua .toString (-1 ));
1594
1594
1595
1595
lua .unref (ref );
1596
1596
}
@@ -1648,7 +1648,7 @@ test "args and errors" {
1648
1648
1649
1649
lua .pushFunction (raisesError );
1650
1650
try expectError (error .Runtime , lua .protectedCall (0 , 0 , 0 ));
1651
- try expectEqualStrings ("some error zig!" , try lua .toBytes (-1 ));
1651
+ try expectEqualStrings ("some error zig!" , try lua .toString (-1 ));
1652
1652
1653
1653
if (ziglua .lang != .lua54 ) return ;
1654
1654
@@ -1681,7 +1681,7 @@ test "traceback" {
1681
1681
try lua .doString ("res = tracebackFn()" );
1682
1682
1683
1683
_ = try lua .getGlobal ("res" );
1684
- try expectEqualStrings ("\n stack traceback:\n \t [string \" res = tracebackFn()\" ]:1: in main chunk" , try lua .toBytes (-1 ));
1684
+ try expectEqualStrings ("\n stack traceback:\n \t [string \" res = tracebackFn()\" ]:1: in main chunk" , try lua .toString (-1 ));
1685
1685
}
1686
1686
1687
1687
test "getSubtable" {
0 commit comments