zig/test/behavior/bugs/1076.zig
Andrew Kelley 4307436b99 move behavior tests from test/stage1/ to test/
And fix test cases to make them pass. This is in preparation for
starting to pass behavior tests with self-hosted.
2021-04-29 15:54:04 -07:00

24 lines
569 B
Zig

const std = @import("std");
const mem = std.mem;
const expect = std.testing.expect;
test "comptime code should not modify constant data" {
testCastPtrOfArrayToSliceAndPtr();
comptime testCastPtrOfArrayToSliceAndPtr();
}
fn testCastPtrOfArrayToSliceAndPtr() void {
{
var array = "aoeu".*;
const x: [*]u8 = &array;
x[0] += 1;
expect(mem.eql(u8, array[0..], "boeu"));
}
{
var array: [4]u8 = "aoeu".*;
const x: [*]u8 = &array;
x[0] += 1;
expect(mem.eql(u8, array[0..], "boeu"));
}
}