File: Test2

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 (41 lines) | stat: -rw-r--r-- 845 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
#
# Curried functions with keyword arguments
#
curry.f(~A = 1, x) =
   private.A = $A
   private.x = $x
   g(~B = 2, y) =
      add($A, $B, $x, $y)

errors = false

# Omit all keywords
i = $(f 10, 20)
if $(not $(equal $i, 33))
    eprintln($"f(10, 20) evaluates to $i, expected 33")
    errors = true
    export

# Only f's keyword
i = $(f 10, 20, ~A = 30)
if $(not $(equal $i, 62))
    eprintln($"f(10, 20, ~A = 30) evaluates to $i, expected 62")
    errors = true
    export

# Only g's keyword
i = $(f 10, 20, ~B = 30)
if $(not $(equal $i, 61))
    eprintln($"f(10, 20, ~B = 30) evaluates to $i, expected 61")
    errors = true
    export

# Everything
i = $(f ~B = 40, 10, 20, ~A = 30)
if $(not $(equal $i, 100))
    eprintln($"f(~B = 40, 10, 20, A = 30) evaluates to $i, expected 100")
    errors = true
    export

if $(errors)
    exit 1