File: Test6

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 (24 lines) | stat: -rw-r--r-- 528 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
#
# Partial applications
#
errors = 0
check(debug, i, j) =
   if $(equal $i, $j)
       println($"$(debug) = $i [SUCCESS]")
   else
       eprintln($"$(debug):
computed  $i
should be $j [FAILURE]")
       errors = $(add $(errors), 1)
       export
   export

f1(a, ?b = 2, ?c = 3, d) =
   value $"a = $a, b = $b, c = $c, d = $d"

f2 = $(apply $(f1), 10, ~b = 11)
check($'f2(13)', $(f2 13), $'a = 10, b = 11, c = 3, d = 13')
check($'f2(~c = 12, 13)', $(f2 ~c = 12, 13), $'a = 10, b = 11, c = 12, d = 13')

if $(errors)
    exit 1