aboutsummaryrefslogtreecommitdiff
path: root/tests/value/reverse.testscript
blob: 921d14bb2f8859a7dc520edf3fa1de81949202b5 (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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# file      : tests/value/reverse.testscript
# license   : MIT; see accompanying LICENSE file

# Test reversal to canonical/original representation.
#

.include ../common.testscript

: name
:
{
  : dir
  :
  $* <<EOI >>EOO
  x = s/foo/bar/
  print ([string] $x)
  print "$x"
  print -e=$x
  EOI
  s/foo/bar/
  s/foo/bar/
  -e=s/foo/bar/
  EOO

  : proj
  :
  $* <<EOI >>EOO
  print ([strings] foo%bar foo% %bar)
  EOI
  foo%bar foo% %bar
  EOO

  : pair
  :
  $* <<EOI >>EOO
  print ([strings] foo@bar foo/@bar/ foo@ @bar @ "@@")
  EOI
  foo@bar foo/@bar/ foo@ @bar @ @@
  EOO

  : proj-pair
  :
  $* <<EOI >>EOO
  print ([strings] xx%foo@yy%bar xx%foo/@yy%bar/)
  EOI
  xx%foo@yy%bar xx%foo/@yy%bar/
  EOO

  : invalid
  :
  : We should be able to represent an invalid name provided it is quoted.
  :
  $* <<EOI >>EOO
  print ([strings] "pkcs11:object=SIGN%20key")
  EOI
  pkcs11:object=SIGN%20key
  EOO
}

: dir-path
:
{
  : rel
  :
  $* <<EOI >>"EOO"
  x = [dir_path] foo/bar/
  print ([string] $x)
  print "$x"
  print "-I$x"
  EOI
  foo/bar/
  foo/bar
  -Ifoo/bar
  EOO

  : root
  :
  if ($cxx.target.class != 'windows')
  {
    $* <<EOI >>EOO
    x = [dir_path] /
    print ([string] $x)
    print "$x"
    print "-I$x"
    EOI
    /
    /
    -I/
    EOO
  }
}

: reduce
:
: Test empty simple value reduction heuristics.
:
{
  : typed
  :
  $* <<EOI >>"EOO"
  x = [string]
  n = [string,null]
  y = [strings] $x
  y += $x
  y += $n
  print $size($y)

  file{*}: y += $x
  file{x}:
  print $size($(file{x}: y))

  for i: $x
    print iteration

  print $null($x[0])
  EOI
  2
  3
  iteration
  false
  EOO

  : untyped
  :
  $* <<EOI >>"EOO"
  x =
  n = [null]
  y = $x
  y += $x
  y += $n
  print $size($y)

  file{*}: y += $x
  file{x}:
  print $size($(file{x}: y))

  for i: $x
    print iteration

  print $null($x[0])
  EOI
  0
  0
  true
  EOO
}