summary refs log tree commit diff stats
path: root/tests/parser/tstrongspaces.nim
blob: 91506daf073bb5314217a108518d4b58ca4cba5c (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
#! strongSpaces

discard """
  output: '''35
77
(Field0: 1, Field1: 2, Field2: 2)
ha
true
tester args
all
all args
'''
"""

echo 2+5 * 5

let foo = 77
echo $foo

echo (1, 2, 2)

template `&`(a, b: int): expr = a and b
template `|`(a, b: int): expr = a - b
template `++`(a, b: int): expr = a + b == 8009

when true:
  let b = 66
  let c = 90
  let bar = 8000
  if foo+4 * 4 == 8 and b&c | 9  ++
      bar:
    echo "ho"
  else:
    echo "ha"

  let booA = foo+4 * 4  -  b&c | 9  +
      bar
  # is parsed as
  let booB = ((foo+4)*4) - ((b&c) | 9) + bar

  echo booA == booB


template `|`(a, b): expr = (if a.len > 0: a else: b)

const
  tester = "tester"
  args = "args"

echo tester & " " & args|"all"
echo "all"  |  tester & " " & args
echo "all"|tester & " " & args
mer, 40); } function stopTimer () { window.clearInterval(timerId); timerId = 0; } function timer () { if (ev) { var scrollY = (ev.y - y); var scrollX = (ev.x - x); var b = scrollY > 0 && doc.documentElement.scrollHeight == (window.innerHeight + window.pageYOffset); var r = scrollX > 0 && doc.documentElement.scrollWidth == (window.innerWidth + window.pageXOffset); var l = scrollX < 0 && window.pageXOffset == 0; var t = scrollY < 0 && window.pageYOffset == 0; var offX = Math.abs(scrollX) < OFFSET; var offY = Math.abs(scrollY) < OFFSET; if ( timerId != 0 && (( b && r ) || ( b && l) || ( b && offX ) || ( t && r ) || ( t && l) || ( t && offX ) || (offY && r) || (offY && l) )) { stopTimer(); return; } window.scrollBy(scrollX - Math.sign(scrollX) * OFFSET, scrollY - Math.sign(scrollY) * OFFSET); } } function mouseMove (e) { if (timerId == 0) { startTimer(); } ev = e; } function init (e) { doc = e.target.ownerDocument; if (window.innerHeight >= doc.documentElement.scrollHeight && window.innerWidth >= doc.documentElement.scrollWidth) { return; } span = doc.createElement("div"); span.style.width = SIZE + "px"; span.style.height = SIZE + "px"; span.style.background = SCROLL_ICON; span.style.left = e.x - (SIZE / 2) + "px"; span.style.top = e.y - (SIZE / 2) + "px"; span.style.position = "fixed"; span.style.fontSize = SIZE + "px"; span.style.opacity = 0.6; cursorStyle = doc.defaultView.getComputedStyle(doc.body, null).cursor; doc.body.style.cursor = "move"; doc.body.appendChild(span); doc.addEventListener('mousemove', mouseMove, false); span = span; } function clear (e) { doc.body.style.cursor = cursorStyle; span.parentNode.removeChild(span); doc.removeEventListener('mousemove', mouseMove, false); stopTimer(); if (span) span = null; if (ev) ev = null; } function mouseUp (e) { /* Simulate click, click event does not work during scrolling */ if (Math.abs(e.x - x) < 5 && Math.abs(e.y - y) < 5) { init(e); window.removeEventListener('mouseup', mouseUp, false); } } function mouseDown (e) { var t = e.target; if (e.button == 0) { if (span) { clear(); } } else if (e.button == 1) { if (span) { clear(); } else if (!t.hasAttribute("href") && !t.hasAttribute("onmousedown") && !(t.hasAttribute("onclick"))) { x = e.x; y = e.y; window.addEventListener('mouseup', mouseUp, false); } } } window.addEventListener('mousedown', mouseDown, false); })();