summaryrefslogtreecommitdiffhomepage
path: root/test/t/integer.rb
blob: 9f70d4a7affd1632b98c65054be47f0b62a69f5f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
##
# Integer ISO Test

assert('Integer', '15.2.8') do
  Integer.class == Class
end

assert('Integer#+', '15.2.8.3.1') do
  a = 1+1
  b = 1+1.0

  a == 2 and b == 2.0
end

assert('Integer#-', '15.2.8.3.2') do
  a = 2-1
  b = 2-1.0

  a == 1 and b == 1.0
end

assert('Integer#*', '15.2.8.3.3') do
  a = 1*1
  b = 1*1.0

  a == 1 and b == 1.0
end

assert('Integer#/', '15.2.8.3.4') do
  a = 2/1
  b = 2/1.0

  a == 2 and b == 2.0
end

assert('Integer#%', '15.2.8.3.5') do
  a = 1%1
  b = 1%1.0
  c = 2%4

  a == 0 and b == 0.0 and c == 2
end

assert('Integer#<=>', '15.2.8.3.6') do
  a = 1<=>0
  b = 1<=>1
  c = 1<=>2

  a == 1 and b == 0 and c == -1
end

assert('Integer#==', '15.2.8.3.7') do
  a = 1==0
  b = 1==1

  a == false and b == true
end