Skip to content

Commit

Permalink
Merge pull request #99 from pedropark99/improve-engine
Browse files Browse the repository at this point in the history
Fix duplicated results from stderr
  • Loading branch information
pedropark99 authored Dec 4, 2024
2 parents 1e193d4 + 1c02ee8 commit f0d14ee
Show file tree
Hide file tree
Showing 17 changed files with 519 additions and 542 deletions.
3 changes: 0 additions & 3 deletions Chapters/02-debugging.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,6 @@ pub fn main() !void {
}
```

```
Result: 50
```

You could also achieve the exact same result by getting a file descriptor object to `stderr`,
then, creating a *writer* object to `stderr`, then, using the `print()` method of this
Expand Down
6 changes: 2 additions & 4 deletions Chapters/03-structs.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,7 @@ its scope.

```{zig}
#| auto_main: false
#| build_type: "run"
#| echo: true
#| results: "hide"
#| build_type: "lib"
const std = @import("std");
const stdout = std.io.getStdOut().writer();
fn foo() !void {
Expand Down Expand Up @@ -684,7 +682,7 @@ By making it a pointer, we can finally alter the value of this function argument
the body of the `add2()` function. You can see that the code example below compiles successfully.

```{zig}
#| build_type: "run"
#| build_type: "lib"
#| auto_main: false
const std = @import("std");
fn add2(x: *u32) void {
Expand Down
9 changes: 0 additions & 9 deletions Chapters/03-unittests.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,6 @@ test "testing error" {
}
```

```
1/1 oom.test.testing error... OK
All 1 tests passed.
```



Expand Down Expand Up @@ -301,11 +297,6 @@ test "arrays are equal?" {
}
```

```
1/1 oom.test.arrays are equal?... OK
All 1 tests passed.
```


At last, you might also want to use the `expectEqualStrings()` function.
As the name suggests, you can use this function to test if two strings
Expand Down
3 changes: 0 additions & 3 deletions Chapters/05-pointers.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ const doubled = 2 * pointer.*;
std.debug.print("{d}\n", .{doubled});
```

```
10
```

This syntax to dereference the pointer is nice. Because we can easily chain it with
methods of the value pointed by the pointer. We can use the `User` struct that we have
Expand Down
6 changes: 4 additions & 2 deletions Chapters/09-data-structures.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ style to the `pop()` method.

```{zig}
#| auto_main: true
#| eval: true
#| build_type: "lib"
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
const allocator = gpa.allocator();
var buffer = try std.ArrayList(u8)
Expand Down Expand Up @@ -399,6 +399,7 @@ that uses the default settings and context.

```{zig}
#| auto_main: false
#| build_type: "lib"
const std = @import("std");
const AutoHashMap = std.hash_map.AutoHashMap;
Expand Down Expand Up @@ -490,7 +491,7 @@ The code example below demonstrates the use of these elements:

```{zig}
#| auto_main: false
#| build_type: "run"
#| build_type: "lib"
const std = @import("std");
const AutoHashMap = std.hash_map.AutoHashMap;
Expand Down Expand Up @@ -644,6 +645,7 @@ resulting object from the `StringHashMap()` function.

```{zig}
#| auto_main: false
#| build_type: "lib"
const std = @import("std");
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
Expand Down
5 changes: 2 additions & 3 deletions Chapters/10-stack-project.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ Having this in mind, makes sense to mark this argument as a comptime argument.

```{zig}
#| auto_main: false
#| build_type: "test"
#| build_type: "lib"
fn max(comptime T: type, a: T, b: T) T {
return if (a > b) a else b;
}
Expand All @@ -305,7 +305,7 @@ This generic function provides a very useful shortcut for us.

```{zig}
#| auto_main: false
#| build_type: "test"
#| build_type: "lib"
const std = @import("std");
fn max(comptime T: type, a: T, b: T) T {
return if (a > b) a else b;
Expand All @@ -324,7 +324,6 @@ Max n2: 89.24
```



### A generic data structure {#sec-generic-struct}

Every data structure that you find in the Zig Standard Library (e.g. `ArrayList`, `HashMap`, etc.)
Expand Down
8 changes: 5 additions & 3 deletions _freeze/Chapters/02-debugging/execute-results/html.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions _freeze/Chapters/03-structs/execute-results/html.json

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions _freeze/Chapters/05-pointers/execute-results/html.json

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions _freeze/Chapters/09-data-structures/execute-results/html.json

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions _freeze/Chapters/10-stack-project/execute-results/html.json

Large diffs are not rendered by default.

151 changes: 75 additions & 76 deletions docs/Chapters/02-debugging.html

Large diffs are not rendered by default.

320 changes: 159 additions & 161 deletions docs/Chapters/03-structs.html

Large diffs are not rendered by default.

123 changes: 61 additions & 62 deletions docs/Chapters/05-pointers.html

Large diffs are not rendered by default.

174 changes: 85 additions & 89 deletions docs/Chapters/09-data-structures.html

Large diffs are not rendered by default.

213 changes: 103 additions & 110 deletions docs/Chapters/10-stack-project.html

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions docs/search.json

Large diffs are not rendered by default.

0 comments on commit f0d14ee

Please sign in to comment.