File: Test4

package info (click to toggle)
omake 0.10.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 14,076 kB
  • sloc: ml: 49,729; ansic: 5,163; makefile: 688; sh: 110
file content (49 lines) | stat: -rw-r--r-- 1,017 bytes parent folder | download | duplicates (3)
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
#
# Curried methods
#
A[] = 1 2 3

A. +=
   X = 1
   curry.f() =
      private.THIS = $(this)
      g(h) =
         h($(THIS))
   g(h) =
      private.THIS = $(this)
      h($(THIS))

B. =
   class B

B. +=
   X = 2

   A.f(items) =>
      if $(equal $X, 2)
          println($"A.f(...) evaluates to 2 [SUCCESS]")
      else
          eprintln($"A.f(...) evaluates to $X, expected 2 [ERROR]")
          exit 1

   A.g(items) =>
      if $(equal $X, 1)
          println($"A.g(...) evaluates to 1 [SUCCESS]")
      else
          eprintln($"A.g(...) evaluates to $X, expected 1 [ERROR]")
          exit 1

   A.f(items) =>
      sum = 0
      foreach(i => ..., $(items))
         sum = $(add $(sum), $i)
         export
      if $(not $(this.instanceof B))
          eprintln($"this is not an instanceof B [ERROR]")
          exit 1
      elseif $(equal $(sum), 6)
          println($"sum evaluates to 6 [SUCCESS]")
      else
          eprintln($"sum evaluates to $(sum), expected 6 [ERROR]")
          exit 1