| author | |
| committer | |
| log | a45db7e853c2aa04ff7a91dbda975f181aa467bd |
| tree | 2f89718ec3edb9a2fec29753d60ffcd630af8698 |
| parent | 5b156031e92c66c1bea71d5eb6c337b23185d65d |
3 files changed, 22 insertions(+), 3 deletions(-)
build.zig+4-1| ... | @@ -33,6 +33,8 @@ pub fn build(b: &Builder) { | ... | @@ -33,6 +33,8 @@ pub fn build(b: &Builder) { |
| 33 | docs_step.dependOn(&docgen_cmd.step); | 33 | docs_step.dependOn(&docgen_cmd.step); |
| 34 | docs_step.dependOn(&docgen_home_cmd.step); | 34 | docs_step.dependOn(&docgen_home_cmd.step); |
| 35 | 35 | ||
| 36 | const test_step = b.step("test", "Run all the tests"); | ||
| 37 | |||
| 36 | if (findLLVM(b)) |llvm| { | 38 | if (findLLVM(b)) |llvm| { |
| 37 | // find the stage0 build artifacts because we're going to re-use config.h and zig_cpp library | 39 | // find the stage0 build artifacts because we're going to re-use config.h and zig_cpp library |
| 38 | const build_info = b.exec([][]const u8{b.zig_exe, "BUILD_INFO"}); | 40 | const build_info = b.exec([][]const u8{b.zig_exe, "BUILD_INFO"}); |
| ... | @@ -72,15 +74,16 @@ pub fn build(b: &Builder) { | ... | @@ -72,15 +74,16 @@ pub fn build(b: &Builder) { |
| 72 | 74 | ||
| 73 | b.default_step.dependOn(&exe.step); | 75 | b.default_step.dependOn(&exe.step); |
| 74 | b.default_step.dependOn(docs_step); | 76 | b.default_step.dependOn(docs_step); |
| 77 | test_step.dependOn(&exe.step); | ||
| 75 | 78 | ||
| 76 | b.installArtifact(exe); | 79 | b.installArtifact(exe); |
| 77 | installStdLib(b); | 80 | installStdLib(b); |
| 81 | |||
| 78 | } | 82 | } |
| 79 | 83 | ||
| 80 | 84 | ||
| 81 | const test_filter = b.option([]const u8, "test-filter", "Skip tests that do not match filter"); | 85 | const test_filter = b.option([]const u8, "test-filter", "Skip tests that do not match filter"); |
| 82 | const with_lldb = b.option(bool, "with-lldb", "Run tests in LLDB to get a backtrace if one fails") ?? false; | 86 | const with_lldb = b.option(bool, "with-lldb", "Run tests in LLDB to get a backtrace if one fails") ?? false; |
| 83 | const test_step = b.step("test", "Run all the tests"); | ||
| 84 | 87 | ||
| 85 | test_step.dependOn(docs_step); | 88 | test_step.dependOn(docs_step); |
| 86 | 89 |
src-self-hosted/main.zig+5| ... | @@ -626,3 +626,8 @@ fn findZigLibDir(allocator: &mem.Allocator) -> %[]u8 { | ... | @@ -626,3 +626,8 @@ fn findZigLibDir(allocator: &mem.Allocator) -> %[]u8 { |
| 626 | 626 | ||
| 627 | return error.FileNotFound; | 627 | return error.FileNotFound; |
| 628 | } | 628 | } |
| 629 | |||
| 630 | test "import tests" { | ||
| 631 | _ = @import("tokenizer.zig"); | ||
| 632 | _ = @import("parser.zig"); | ||
| 633 | } |
src-self-hosted/tokenizer.zig+13-2| ... | @@ -204,6 +204,7 @@ pub const Tokenizer = struct { | ... | @@ -204,6 +204,7 @@ pub const Tokenizer = struct { |
| 204 | LineComment, | 204 | LineComment, |
| 205 | Zero, | 205 | Zero, |
| 206 | IntegerLiteral, | 206 | IntegerLiteral, |
| 207 | IntegerLiteralWithRadix, | ||
| 207 | NumberDot, | 208 | NumberDot, |
| 208 | FloatFraction, | 209 | FloatFraction, |
| 209 | FloatExponentUnsigned, | 210 | FloatExponentUnsigned, |
| ... | @@ -454,7 +455,7 @@ pub const Tokenizer = struct { | ... | @@ -454,7 +455,7 @@ pub const Tokenizer = struct { |
| 454 | }, | 455 | }, |
| 455 | State.Zero => switch (c) { | 456 | State.Zero => switch (c) { |
| 456 | 'b', 'o', 'x' => { | 457 | 'b', 'o', 'x' => { |
| 457 | state = State.IntegerLiteral; | 458 | state = State.IntegerLiteralWithRadix; |
| 458 | }, | 459 | }, |
| 459 | else => { | 460 | else => { |
| 460 | // reinterpret as a normal number | 461 | // reinterpret as a normal number |
| ... | @@ -469,6 +470,16 @@ pub const Tokenizer = struct { | ... | @@ -469,6 +470,16 @@ pub const Tokenizer = struct { |
| 469 | 'p', 'P', 'e', 'E' => { | 470 | 'p', 'P', 'e', 'E' => { |
| 470 | state = State.FloatExponentUnsigned; | 471 | state = State.FloatExponentUnsigned; |
| 471 | }, | 472 | }, |
| 473 | '0'...'9' => {}, | ||
| 474 | else => break, | ||
| 475 | }, | ||
| 476 | State.IntegerLiteralWithRadix => switch (c) { | ||
| 477 | '.' => { | ||
| 478 | state = State.NumberDot; | ||
| 479 | }, | ||
| 480 | 'p', 'P' => { | ||
| 481 | state = State.FloatExponentUnsigned; | ||
| 482 | }, | ||
| 472 | '0'...'9', 'a'...'f', 'A'...'F' => {}, | 483 | '0'...'9', 'a'...'f', 'A'...'F' => {}, |
| 473 | else => break, | 484 | else => break, |
| 474 | }, | 485 | }, |
| ... | @@ -485,7 +496,7 @@ pub const Tokenizer = struct { | ... | @@ -485,7 +496,7 @@ pub const Tokenizer = struct { |
| 485 | }, | 496 | }, |
| 486 | }, | 497 | }, |
| 487 | State.FloatFraction => switch (c) { | 498 | State.FloatFraction => switch (c) { |
| 488 | 'p', 'P', 'e', 'E' => { | 499 | 'p', 'P' => { |
| 489 | state = State.FloatExponentUnsigned; | 500 | state = State.FloatExponentUnsigned; |
| 490 | }, | 501 | }, |
| 491 | '0'...'9', 'a'...'f', 'A'...'F' => {}, | 502 | '0'...'9', 'a'...'f', 'A'...'F' => {}, |