summary refs log tree commit diff stats
path: root/tests/misc/tloops.nim
blob: b160500af27d8bd6f38413995bf3735ab684a109 (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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# Test nested loops and some other things

proc andTest() =
  var a = 0 == 5 and 6 == 6

proc incx(x: var int) = # is built-in proc
  x = x + 1

proc decx(x: var int) =
  x = x - 1

proc First(y: var int) =
  var x: int
  i_ncx(x)
  if x == 10:
    y = 0
  else:
    if x == 0:
      incx(x)
    else:
      x=11

proc TestLoops() =
  var i, j: int
  while i >= 0:
    if i mod 3 == 0:
      break
    i = i + 1
    while j == 13:
      j = 13
      break
    break

  while true:
    break


proc Foo(n: int): int =
    var
        a, old: int
        b, c: bool
    F_irst(a)
    if a == 10:
        a = 30
    elif a == 11:
        a = 22
    elif a == 12:
        a = 23
    elif b:
        old = 12
    else:
        a = 40

    #
    b = false or 2 == 0 and 3 == 9
    a = 0 + 3 * 5 + 6 + 7 + +8 # 36
    while b:
        a = a + 3
    a = a + 5
    write(stdout, "Hello!")


# We should come till here :-)
discard Foo(345)

# test the new type symbol lookup feature:

type
  MyType[T] = tuple[
    x, y, z: T]
  MyType2 = tuple[x, y: float]

proc main[T]() =
  var myType: MyType[T]
  var b: MyType[T]
  b = (1, 2, 3)
  myType = b
  echo myType

  var myType2: MyType2
  var c: MyType2
  c = (1.0, 2.0)
  myType2 = c
  echo myType2

main[int]()
"p">></dt><dd> <dl> <dt><font face="helvetica, arial"><a href="ranger.gui.mouse_event.html#MouseEvent">MouseEvent</a> </font></dt></dl> </dd> </dl> <p> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> <tr bgcolor="#ffc8d8"> <td colspan=3 valign=bottom>&nbsp;<br> <font color="#000000" face="helvetica, arial"><a name="MouseEvent">class <strong>MouseEvent</strong></a>(<a href="builtins.html#object">builtins.object</a>)</font></td></tr> <tr><td bgcolor="#ffc8d8"><tt>&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td> <td width="100%">Methods defined here:<br> <dl><dt><a name="MouseEvent-__init__"><strong>__init__</strong></a>(self, getmouse)</dt><dd><tt>Creates&nbsp;a&nbsp;<a href="#MouseEvent">MouseEvent</a>&nbsp;<a href="builtins.html#object">object</a>&nbsp;from&nbsp;the&nbsp;result&nbsp;of&nbsp;win.getmouse()</tt></dd></dl> <dl><dt><a name="MouseEvent-alt"><strong>alt</strong></a>(self)</dt></dl> <dl><dt><a name="MouseEvent-ctrl"><strong>ctrl</strong></a>(self)</dt></dl> <dl><dt><a name="MouseEvent-key_invalid"><strong>key_invalid</strong></a>(self)</dt></dl> <dl><dt><a name="MouseEvent-pressed"><strong>pressed</strong></a>(self, n)</dt><dd><tt>Returns&nbsp;whether&nbsp;the&nbsp;mouse&nbsp;key&nbsp;n&nbsp;is&nbsp;pressed</tt></dd></dl> <dl><dt><a name="MouseEvent-shift"><strong>shift</strong></a>(self)</dt></dl> <hr> Data descriptors defined here:<br> <dl><dt><strong>__dict__</strong></dt> <dd><tt>dictionary&nbsp;for&nbsp;instance&nbsp;variables&nbsp;(if&nbsp;defined)</tt></dd> </dl> <dl><dt><strong>__weakref__</strong></dt> <dd><tt>list&nbsp;of&nbsp;weak&nbsp;references&nbsp;to&nbsp;the&nbsp;object&nbsp;(if&nbsp;defined)</tt></dd> </dl> <hr> Data and other attributes defined here:<br> <dl><dt><strong>PRESSED</strong> = [0, 2, 128, 8192, 524288]</dl> </td></tr></table></td></tr></table> </body></html>