Skip to content

Commit f633157

Browse files
committed
refactor: replace Error.* with error.*
There isn't a reason to use the full error type everywhere
1 parent 7650761 commit f633157

File tree

2 files changed

+69
-69
lines changed

2 files changed

+69
-69
lines changed

src/tests.zig

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,14 @@ test "initialization" {
7676
lua.deinit();
7777

7878
// attempt to initialize the Zig wrapper with no memory
79-
try expectError(Error.Memory, Lua.init(testing.failing_allocator));
79+
try expectError(error.Memory, Lua.init(testing.failing_allocator));
8080

8181
// use the library directly
8282
lua = try Lua.newState(alloc, null);
8383
lua.close();
8484

8585
// use the library with a bad AllocFn
86-
try expectError(Error.Memory, Lua.newState(failing_alloc, null));
86+
try expectError(error.Memory, Lua.newState(failing_alloc, null));
8787

8888
// use the auxiliary library (uses libc realloc and cannot be checked for leaks!)
8989
lua = try Lua.newStateAux();
@@ -332,9 +332,9 @@ test "executing string contents" {
332332
try expectEqual(LuaType.number, try lua.getGlobalEx("a"));
333333
try expectEqual(@as(i64, 12), try lua.toInteger(1));
334334

335-
try expectError(Error.Syntax, lua.loadString("bad syntax"));
335+
try expectError(error.Syntax, lua.loadString("bad syntax"));
336336
try lua.loadString("a = g()");
337-
try expectError(Error.Runtime, lua.protectedCall(0, 0, 0));
337+
try expectError(error.Runtime, lua.protectedCall(0, 0, 0));
338338
}
339339

340340
test "filling and checking the stack" {
@@ -355,7 +355,7 @@ test "filling and checking the stack" {
355355
try expectEqual(@as(i32, 30), lua.getTop());
356356

357357
// this should fail (beyond max stack size)
358-
try expectError(Error.Fail, lua.checkStack(1_000_000));
358+
try expectError(error.Fail, lua.checkStack(1_000_000));
359359

360360
// this is small enough it won't fail (would raise an error if it did)
361361
lua.checkStackAux(40, null);
@@ -547,7 +547,7 @@ test "function registration" {
547547

548548
try lua.doString("funcs.add(10, 20)");
549549
try lua.doString("funcs.sub('10', 20)");
550-
try expectError(Error.Runtime, lua.doString("funcs.placeholder()"));
550+
try expectError(error.Runtime, lua.doString("funcs.placeholder()"));
551551
}
552552

553553
test "panic fn" {
@@ -657,7 +657,7 @@ test "table access" {
657657
lua.pushString("zig");
658658
lua.rawSetTable(1);
659659

660-
try expectError(Error.Fail, lua.getMetatable(1));
660+
try expectError(error.Fail, lua.getMetatable(1));
661661

662662
// create a metatable (it isn't a useful one)
663663
lua.newTable();
@@ -667,7 +667,7 @@ test "table access" {
667667

668668
try lua.getMetatable(1);
669669
_ = try lua.getMetaField(1, "__len");
670-
try expectError(Error.Fail, lua.getMetaField(1, "__index"));
670+
try expectError(error.Fail, lua.getMetaField(1, "__index"));
671671

672672
lua.pushBoolean(true);
673673
lua.setField(1, "bool");
@@ -702,7 +702,7 @@ test "conversions" {
702702
var value: Integer = undefined;
703703
try Lua.numberToInteger(3.14, &value);
704704
try expectEqual(@as(Integer, 3), value);
705-
try expectError(Error.Fail, Lua.numberToInteger(@intToFloat(Number, ziglua.max_integer) + 10, &value));
705+
try expectError(error.Fail, Lua.numberToInteger(@intToFloat(Number, ziglua.max_integer) + 10, &value));
706706

707707
// string conversion
708708
try lua.stringToNumber("1");
@@ -713,9 +713,9 @@ test "conversions" {
713713
try expect(lua.isNumber(-1));
714714
try expectEqual(@as(Number, 1.0), try lua.toNumber(-1));
715715

716-
try expectError(Error.Fail, lua.stringToNumber("a"));
717-
try expectError(Error.Fail, lua.stringToNumber("1.a"));
718-
try expectError(Error.Fail, lua.stringToNumber(""));
716+
try expectError(error.Fail, lua.stringToNumber("a"));
717+
try expectError(error.Fail, lua.stringToNumber("1.a"));
718+
try expectError(error.Fail, lua.stringToNumber(""));
719719

720720
// index conversion
721721
try expectEqual(@as(i32, 2), lua.absIndex(-1));
@@ -812,8 +812,8 @@ test "userdata and uservalues" {
812812
try expectEqual(LuaType.string, try lua.getIndexUserValue(1, 2));
813813
try expectEqualStrings("test string", try lua.toBytes(-1));
814814

815-
try expectError(Error.Fail, lua.setIndexUserValue(1, 3));
816-
try expectError(Error.Fail, lua.getIndexUserValue(1, 3));
815+
try expectError(error.Fail, lua.setIndexUserValue(1, 3));
816+
try expectError(error.Fail, lua.getIndexUserValue(1, 3));
817817

818818
try expectEqual(data, ziglua.opaqueCast(Data, try lua.toUserdata(1)));
819819
try expectEqual(@ptrCast(*const anyopaque, data), @alignCast(@alignOf(Data), try lua.toPointer(1)));
@@ -937,7 +937,7 @@ test "raise error" {
937937
}.inner;
938938

939939
lua.pushFunction(ziglua.wrap(makeError));
940-
try expectError(Error.Runtime, lua.protectedCall(0, 0, 0));
940+
try expectError(error.Runtime, lua.protectedCall(0, 0, 0));
941941
try expectEqualStrings("makeError made an error", try lua.toBytes(-1));
942942
}
943943

@@ -1073,7 +1073,7 @@ test "debug upvalues" {
10731073
try lua.getGlobal("addone");
10741074

10751075
// index doesn't exist
1076-
try expectError(Error.Fail, lua.getUpvalue(1, 2));
1076+
try expectError(error.Fail, lua.getUpvalue(1, 2));
10771077

10781078
// inspect the upvalue (should be x)
10791079
try expectEqualStrings("x", try lua.getUpvalue(-1, 1));
@@ -1085,7 +1085,7 @@ test "debug upvalues" {
10851085
try lua.setUpvalue(-2, 1);
10861086

10871087
// test a bad index (the valid one's result is unpredicable)
1088-
try expectError(Error.Fail, lua.upvalueId(-1, 2));
1088+
try expectError(error.Fail, lua.upvalueId(-1, 2));
10891089

10901090
// call the new function (should return 7)
10911091
lua.pushNumber(2);
@@ -1109,7 +1109,7 @@ test "getstack" {
11091109
var lua = try Lua.init(testing.allocator);
11101110
defer lua.deinit();
11111111

1112-
try expectError(Error.Fail, lua.getStack(1));
1112+
try expectError(error.Fail, lua.getStack(1));
11131113

11141114
const function = struct {
11151115
fn inner(l: *Lua) i32 {
@@ -1225,7 +1225,7 @@ test "get global fail" {
12251225
var lua = try Lua.init(testing.allocator);
12261226
defer lua.deinit();
12271227

1228-
try expectError(Error.Fail, lua.getGlobal("foo"));
1228+
try expectError(error.Fail, lua.getGlobal("foo"));
12291229
}
12301230

12311231
test "metatables" {

0 commit comments

Comments
 (0)