File tree Expand file tree Collapse file tree 6 files changed +437
-154
lines changed
Expand file tree Collapse file tree 6 files changed +437
-154
lines changed Original file line number Diff line number Diff line change @@ -328,6 +328,20 @@ pub fn build(b: *std.Build) void {
328328 const test_step = b .step ("test" , "Run unit tests" );
329329 test_step .dependOn (& run_tests .step );
330330
331+ // Inline zig tests for interpreter module (discovers tests in all imported files)
332+ const interpreter_tests = b .addTest (.{
333+ .root_module = b .createModule (.{
334+ .root_source_file = .{ .src_path = .{ .owner = b , .sub_path = "src/interpreter/main.zig" } },
335+ .target = target ,
336+ .optimize = optimize ,
337+ }),
338+ });
339+ interpreter_tests .root_module .addImport ("primitives" , primitives_module );
340+ interpreter_tests .root_module .addImport ("bytecode" , bytecode_module );
341+ interpreter_tests .root_module .addImport ("context" , context_module );
342+ const run_interpreter_tests = b .addRunArtifact (interpreter_tests );
343+ test_step .dependOn (& run_interpreter_tests .step );
344+
331345 // Precompile unit tests - these are run via zig test command in CI
332346 // The command needs to link libc and include all modules
333347 // See .github/workflows/ci.yml for the full command
Original file line number Diff line number Diff line change @@ -68,7 +68,6 @@ fn benchmarkStackOperations() !void {
6868
6969 const iterations = 100_000 ;
7070 var stack = interpreter .Stack .new ();
71- defer stack .deinit ();
7271
7372 const start_time = std .time .nanoTimestamp ();
7473
Original file line number Diff line number Diff line change @@ -145,7 +145,6 @@ pub const FrameResult = struct {
145145 pub fn deinit (self : * FrameResult ) void {
146146 self .result .deinit ();
147147 self .memory .deinit ();
148- self .stack .deinit ();
149148 }
150149};
151150
Original file line number Diff line number Diff line change @@ -391,7 +391,6 @@ pub const Interpreter = struct {
391391 /// Deinitialize the interpreter
392392 pub fn deinit (self : * Interpreter ) void {
393393 self .bytecode .deinit ();
394- self .stack .deinit ();
395394 self .memory .deinit ();
396395 }
397396
Original file line number Diff line number Diff line change @@ -45,19 +45,6 @@ pub const testing = struct {
4545 std .debug .print ("Gas tests passed.\n " , .{});
4646 }
4747
48- pub fn testStack () ! void {
49- var stack = Stack .new ();
50- std .debug .assert (stack .len () == 0 );
51-
52- try stack .push (@as (primitives .U256 , 1 ));
53- std .debug .assert (stack .len () == 1 );
54-
55- const value = stack .pop () orelse return error .StackEmpty ;
56- std .debug .assert (value == @as (primitives .U256 , 1 ));
57-
58- std .debug .print ("Stack tests passed.\n " , .{});
59- }
60-
6148 pub fn testMemory () ! void {
6249 var memory = Memory .new ();
6350 std .debug .assert (memory .size () == 0 );
You can’t perform that action at this time.
0 commit comments