diff options
| -rw-r--r-- | doc/langref.html.in | 6 | ||||
| -rw-r--r-- | doc/langref/test_coerce_slices_arrays_and_pointers.zig | 7 | ||||
| -rw-r--r-- | test/behavior/math.zig | 2 |
3 files changed, 12 insertions, 3 deletions
diff --git a/doc/langref.html.in b/doc/langref.html.in index e8189e5c42..139c19211e 100644 --- a/doc/langref.html.in +++ b/doc/langref.html.in @@ -3215,7 +3215,7 @@ fn createFoo(param: i32) !Foo { to increase their development pace. </p> <p> - Error Return Traces are enabled by default in {#link|Debug#} and {#link|ReleaseSafe#} builds and disabled by default in {#link|ReleaseFast#} and {#link|ReleaseSmall#} builds. + Error Return Traces are enabled by default in {#link|Debug#} builds and disabled by default in {#link|ReleaseFast#}, {#link|ReleaseSafe#} and {#link|ReleaseSmall#} builds. </p> <p> There are a few ways to activate this error return tracing feature: @@ -5179,7 +5179,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val <pre>{#syntax#}@mod(numerator: T, denominator: T) T{#endsyntax#}</pre> <p> Modulus division. For unsigned integers this is the same as - {#syntax#}numerator % denominator{#endsyntax#}. Caller guarantees {#syntax#}denominator > 0{#endsyntax#}, otherwise the + {#syntax#}numerator % denominator{#endsyntax#}. Caller guarantees {#syntax#}denominator != 0{#endsyntax#}, otherwise the operation will result in a {#link|Remainder Division by Zero#} when runtime safety checks are enabled. </p> <ul> @@ -5284,7 +5284,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val <pre>{#syntax#}@rem(numerator: T, denominator: T) T{#endsyntax#}</pre> <p> Remainder division. For unsigned integers this is the same as - {#syntax#}numerator % denominator{#endsyntax#}. Caller guarantees {#syntax#}denominator > 0{#endsyntax#}, otherwise the + {#syntax#}numerator % denominator{#endsyntax#}. Caller guarantees {#syntax#}denominator != 0{#endsyntax#}, otherwise the operation will result in a {#link|Remainder Division by Zero#} when runtime safety checks are enabled. </p> <ul> diff --git a/doc/langref/test_coerce_slices_arrays_and_pointers.zig b/doc/langref/test_coerce_slices_arrays_and_pointers.zig index b2fdb6c787..67b2687163 100644 --- a/doc/langref/test_coerce_slices_arrays_and_pointers.zig +++ b/doc/langref/test_coerce_slices_arrays_and_pointers.zig @@ -67,4 +67,11 @@ test "*T to *[1]T" { try expect(z[0] == 1234); } +// Sentinel-terminated slices can be coerced into sentinel-terminated pointers +test "[:x]T to [*:x]T" { + const buf: [:0]const u8 = "hello"; + const buf2: [*:0]const u8 = buf; + try expect(buf2[4] == 'o'); +} + // test diff --git a/test/behavior/math.zig b/test/behavior/math.zig index 0f6dc8459d..08ebf3fe22 100644 --- a/test/behavior/math.zig +++ b/test/behavior/math.zig @@ -527,6 +527,8 @@ fn testIntDivision() !void { try expect(rem(i32, 10, 12) == 10); try expect(rem(i32, -14, 12) == -2); try expect(rem(i32, -2, 12) == -2); + try expect(rem(i32, 118, -12) == 10); + try expect(rem(i32, -14, -12) == -2); try expect(rem(i16, -118, 12) == -10); try expect(divTrunc(i20, 20, -5) == -4); |
