summary refs log tree commit diff stats
path: root/tests/cpp/tcppraise.nim
blob: f03956d4c778658050f2706d029354d6e73aabc8 (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
discard """
  targets: "cpp"
  output: '''foo
bar
Need odd and >= 3 digits##
baz
caught
--------
Triggered raises2
Raising ValueError
'''
"""

# bug #1888
echo "foo"
try:
  echo "bar"
  raise newException(ValueError, "Need odd and >= 3 digits")
#  echo "baz"
except ValueError:
  echo getCurrentExceptionMsg(), "##"
echo "baz"


# bug 7232
try:
 discard
except KeyError, ValueError:
  echo "except handler" # should not be invoked


#bug 7239
try:
  try:
    raise newException(ValueError, "asdf")
  except KeyError, ValueError:
    raise
except:
  echo "caught"


# issue 5549

var strs: seq[string] = @[]

try:
  discard
finally:
  for foobar in strs:
    discard


# issue #11118
echo "--------"
proc raises() =
  raise newException(ValueError, "Raising ValueError")

proc raises2() =
  try:
    raises()
  except ValueError as e:
    echo "Triggered raises2"
    raise e

try:
  raises2()
except:
  echo getCurrentExceptionMsg()
  discard

doAssert: getCurrentException() == nil