aboutsummaryrefslogtreecommitdiff
path: root/tests/function/builtin/testscript
blob: 82df68357914ed8f50fca3ac86b96db5c7296709 (plain)
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
# file      : tests/function/path/testscript
# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
# license   : MIT; see accompanying LICENSE file

.include ../../common.test

: type
:
{
  $* <'print $type([string])'      >'string'  : empty-typed
  $* <'print $type("")'            >''        : empty-untyped

  $* <'print $type([string null])' >'string'  : null-typed
  $* <'print $type([null])'        >''        : null-untyped

  $* <'print $type([string] abc)'  >'string'  : value-typed
  $* <'print $type(abc)'           >''        : value-untyped
}

: null
:
{
  $* <'print $null("")'     >'false'       : empty
  $* <'print $null(abc)'    >'false'       : value
  $* <'print $null([null])' >'true'        : null
}

: empty
:
{
  $* <<EOI     >'true'                       : empty-untyped
  x =
  print $empty($x)
  EOI

  $* <'print $empty([string])'     >'true'   : empty-typed
  $* <'print $empty(abc)'          >'false'  : name
  $* <'print $empty(abc cxx{foo})' >'false'  : names
  $* <'print $empty([bool] false)' >'false'  : bool
}

: identity
:
{
  $* <'print       $identity([string])'        >'';
  $* <'print $type($identity([string]))'       >'string'   : empty-typed

  $* <'print       $identity("")'              >'{}';
  $* <'print $type($identity(""))'             >''         : empty-untyped

  $* <'print       $identity([string null])'   >'[null]';
  $* <'print $type($identity([string null]))'  >'string'   : null-typed

  $* <'print       $identity([null])'          >'[null]';
  $* <'print $type($identity([null]))'         >''         : null-untyped

  $* <'print       $identity([string] abc)'    >'abc';
  $* <'print $type($identity([string] abc))'   >'string'   : typed

  $* <'print       $identity(abc)'             >'abc';
  $* <'print $type($identity(abc))'            >''         : untyped
}