v2 / vlib / v / tests / concurrency / volatile_vars_test.v
14 lines · 13 sloc · 226 bytes · 6488041a749df9762348d019c4223908c476f2e2
Raw
1fn test_volatile_var() {
2 mut volatile zzz := 123
3 assert zzz == 123
4}
5
6fn test_volatile_pointer() {
7 x := 123
8 y := 456
9 mut volatile p := unsafe { &x }
10 println(p)
11 p = unsafe { &y }
12 println(p)
13 assert unsafe { *p == y }
14}
15