Merge: doc: fixed some typos and other misc. corrections
[nit.git] / tests / test_fix_int.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # This file is free software, which comes along with NIT. This software is
4 # distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
5 # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
6 # PARTICULAR PURPOSE. You can modify it is you want, provided this header
7 # is kept unaltered, and a notification of the changes is added.
8 # You are allowed to redistribute it and sell it, alone or is a part of
9 # another product.
10
11 # Tests for the fixed-length integers variant of standard
12 module test_fix_int
13
14 private fun test_int(i, j, l: Numeric) do
15 print ""
16 var k = i + j
17
18 print k
19 print k.to_i
20 print k.to_b
21
22 k = l + j
23
24 print k
25 print k.to_i
26 print k.to_b
27
28 print k.to_i8
29 print k.to_i16
30 print k.to_u16
31 print k.to_i32
32 print ""
33 end
34
35 var i: Numeric
36 var j: Numeric
37 var l: Numeric
38
39 j = 126i8
40 i = 2i8
41 l = 1i8
42
43 test_int(i, j, l)
44
45 j = 32766i16
46 i = 2i16
47 l = 1i16
48
49 test_int(i, j, l)
50
51 j = 65534u16
52 i = 2u16
53 l = 1u16
54
55 test_int(i, j, l)
56
57 j = 2147483646i32
58 i = 2i32
59 l = 1i32
60
61 test_int(i, j, l)
62
63 j = 4294967294u32
64 i = 2u32
65 l = 1u32
66
67 test_int(i, j, l)
68
69 j = 254u8
70 i = 2u8
71 l = 1u8
72
73 test_int(i, j, l)
74
75 j = 254
76 i = 2
77 l = 1
78
79 test_int(i, j, l)