Advertisement
Guest User

Untitled

a guest
Mar 28th, 2019
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.57 KB | None | 0 0
  1. const std = @import("std");
  2. const warn = std.debug.warn;
  3.  
  4. pub fn main() void {
  5.  
  6. }
  7.  
  8. test "doesn't work" {
  9.   const Test = struct {
  10.       value: []i32
  11.   };
  12.  
  13.   var tests = []Test {
  14.       Test {.value=&[]i32{24, 2}},
  15.   };
  16.  
  17.   for (tests) |atest| {
  18.       atest.value[0] = 0;
  19.       warn("{}\n", atest.value[0]);
  20.   }
  21. }
  22.  
  23. test "works" {
  24.   const Test = struct {
  25.       value: []i32
  26.   };
  27.  
  28.   var a = []i32{24, 2};
  29.   var tests = []Test {
  30.       Test {.value=&a},
  31.   };
  32.  
  33.   for (tests) |atest| {
  34.       atest.value[0] = 0;
  35.       warn("{}\n", atest.value[0]);
  36.   }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement