ttypedarray.nim 910 B

123456789101112131415161718192021222324252627
  1. discard """
  2. matrix: "--jsbigint64:off -d:nimStringHash2; --jsbigint64:on"
  3. """
  4. import std/private/jsutils
  5. proc main()=
  6. template fn(a): untyped = jsConstructorName(a)
  7. doAssert fn(array[2, int8].default) == "Int8Array"
  8. doAssert fn(array[2, uint8].default) == "Uint8Array"
  9. doAssert fn(array[2, byte].default) == "Uint8Array"
  10. doAssert fn(array[2, char].default) == "Uint8Array"
  11. whenJsNoBigInt64: discard
  12. do:
  13. doAssert fn(array[2, uint64].default) == "BigUint64Array"
  14. doAssert fn([1'u8]) == "Uint8Array"
  15. doAssert fn([1'u16]) == "Uint16Array"
  16. doAssert fn([byte(1)]) == "Uint8Array"
  17. doAssert fn([1.0'f32]) == "Float32Array"
  18. doAssert fn(array[2, float32].default) == "Float32Array"
  19. doAssert fn(array[2, float].default) == "Float64Array"
  20. doAssert fn(array[2, float64].default) == "Float64Array"
  21. doAssert fn([1.0]) == "Float64Array"
  22. doAssert fn([1.0'f64]) == "Float64Array"
  23. main()