summary refs log tree commit diff stats
path: root/tests/misc/tunsignedinc.nim
blob: 9d1a4bbb4a871db7a1bafe74fcc4447f48775e1f (plain) (blame)
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
block: # bug #2427
  var x = 0'u8
  dec x # OverflowDefect
  x -= 1 # OverflowDefect
  x = x - 1 # No error

  doAssert(x == 253'u8)

block:
  var x = 130'u8
  x += 130'u8
  doAssert(x == 4'u8)

block:
  var x = 40000'u16
  x = x + 40000'u16
  doAssert(x == 14464'u16)

block:
  var x = 4000000000'u32
  x = x + 4000000000'u32
  doAssert(x == 3705032704'u32)

block:
  var x = 123'u16
  x -= 125
  doAssert(x == 65534'u16)

block t4175:
  let i = 0u - 1u
  const j = 0u - 1u
  doAssert i == j
  doAssert j + 1u == 0u