// #target: macos-x64

module test;
import std::io;

macro print_type_info(...)
{
    $for var $i = 0; $i < $vacount; $i++:
        io::printfn("type: %s", $vatype[$i].nameof);
        io::printfn("%s.sizeof = %d", $vatype[$i].nameof, $vatype[$i].sizeof);
        io::printfn("%s.min = %s", $vatype[$i].nameof, $vatype[$i].min);
        io::printfn("%s.max = %s\n", $vatype[$i].nameof, $vatype[$i].max);
    $endfor;
}

fn void main()
{
    io::printfn("Unsigned integers:");
    print_type_info(char, ushort, uint, ulong, uptr, usz, usz);
    io::printfn("Signed integers:");
    print_type_info(ichar, short, int, long, iptr, isz, isz);
    io::printfn("Floats:");
    print_type_info(float, double);
}

/* #expect: test.ll

  i64 0
  i64 1
  i8 0
  i8 -1
  i16 0
  i16 -1
  i64 4
  i64 2
  i32 0
  i32 -1
  i64 8
  i64 0
  i64 -1
  i64 8
  i64 0
  i64 -1
  i64 8
  i64 0
  i64 -1
  i64 8
  i64 0
  i64 -1
  i64 1
  i8 -128
  i8 127
  i64 2
  i16 -32768
  i16 32767
  i64 4
  i32 -2147483648
  i32 2147483647
  i64 8
  i64 -9223372036854775808
  i64 9223372036854775807
  i64 8
  i64 -9223372036854775808
  i64 9223372036854775807
  i64 8
  i64 -9223372036854775808
  i64 9223372036854775807
  i64 8
  i64 -9223372036854775808
  i64 9223372036854775807
  i64 4
  float 0xC7EFFFFFE0000000
  float 0x47EFFFFFE0000000
  i64 8
  double 0xFFEFFFFFFFFFFFFF
  double 0x7FEFFFFFFFFFFFFF