/t/basic/01intarray.t

http://github.com/NotFound/winxed · Raku · 37 lines · 27 code · 9 blank · 1 comment · 7 complexity · e06b08aafebdf12c283594e98159d8c2 MD5 · raw file

  1. #! winxed
  2. // Basic tests for int array
  3. using extern Test.More plan, is, ok;
  4. function main()
  5. {
  6. plan(14);
  7. int noinit [];
  8. ok(noinit instanceof "ResizableIntegerArray", "type of non initialized");
  9. is(elements(noinit), 0, "size of non initialized");
  10. int a []= [ 7, 42 ];
  11. ok(a instanceof "ResizableIntegerArray", "type of initialized");
  12. is(elements(a), 2, "size of initialized");
  13. is(a[0], 7, "first value");
  14. is(a[1], 42, "second value");
  15. int b [2];
  16. ok(b instanceof "FixedIntegerArray", "type of non initialized with size");
  17. is(elements(b), 2, "size of non initialized with size");
  18. int c [2] = [ 7, 42 ];
  19. ok(c instanceof "FixedIntegerArray", "type of initialized with size");
  20. is(elements(c), 2, "size of initialized with size");
  21. is(c[0], 7, "first value");
  22. is(c[1], 42, "second value");
  23. int size= 4;
  24. int d[size];
  25. ok(c instanceof "FixedIntegerArray", "type of non initialized with size non constant");
  26. is(elements(d), size, "size of non initialized with size non constant");
  27. }
  28. // End