aboutsummaryrefslogtreecommitdiff
path: root/tests/build-class-expr/testscript
blob: 006d12d05e24628c712b12942d0c209eccc523df (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
# file      : tests/build-class-expr/testscript
# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd
# license   : MIT; see accompanying LICENSE file

: valid
:
{
  test.options += -p

  : roundtrip
  :
  $* <<EOF >>EOF
    a
    a b
    a : -b
    a : -b +c
    +g
    +gcc
    +gcc-libc++
    +!gcc
    +gcc -windows
    +gcc &linux
    +gcc &linux +( +msvc +windows &!optimized )
    +!windows &( +gcc +clang ) +( +windows &msvc )
    -windows
    EOF

   $* <'a :' >'a' : no-expr
}

: invalid
:
{
  test.options += -p

  $* <''          2>"empty class expression"                          != 0 : empty1
  $* <'+( )'      2>"empty nested class expression"                   != 0 : empty2
  $* <':'         2>"underlying class set expected"                   != 0 : und-exprected1
  $* <': a'       2>"underlying class set expected"                   != 0 : und-exprected2
  $* <'~a'        2>"class name '~a' starts with '~'"                 != 0 : invalid-und
  $* <'x : a'     2>"class term 'a' must start with '+', '-', or '&'" != 0 : no-op
  $* <'+'         2>"empty class name"                                != 0 : no-name1
  $* <'+!'        2>"empty class name"                                != 0 : no-name2
  $* <'+a=b'      2>"class name 'a=b' contains '='"                   != 0 : invalid-char1
  $* <'+-a'       2>"class name '-a' starts with '-'"                 != 0 : invalid-char2
  $* <'+( +a'     2>"nested class expression must be closed with ')'" != 0 : not-closed
  $* <'+a )'      2>"class term expected instead of ')'"              != 0 : expected-name1
  $* <'+( +b ) )' 2>"class term expected instead of ')'"              != 0 : expected-name2
  $* <'+( -a )'   2>"class term '-a' must start with '+'"             != 0 : first-subtract
}

: match
:
{
  : non-empty-class-list
  :
  {
    test.arguments += a b c

    $* <'+a'
    $* <'+!x'
    $* <'+a +x'
    $* <'+a +!x'
    $* <'+a -x'
    $* <'+a -!b'
    $* <'+a -b +c'
    $* <'+a &b'
    $* <'+a &!y'

    $* <'+a +( +b )'
    $* <'+a +( +x )'
    $* <'+a +!( +b )'
    $* <'+a +!( +x )'
    $* <'+a &( +b )'
    $* <'+a &!( +x )'
    $* <'+a -( +x )'
    $* <'+a -!( +b )'
    $* <'+( +b -c +a )'
    $* <'+a &( +b -c +a )'
    $* <'+a &( +b -c +( +a -b ) +c )'

    $* <'a : +c'
    $* <'a : -x'
  }

  : empty-class-list
  :
  {
    $* <'+!x'
  }

  : base
  :
  {
    test.arguments += a:x b:y c

    $* <'+y'
  }
}

: mismatch
:
{
  : non-empty-class-list
  :
  {
    test.arguments += a b c

    $* <'+!a'    == 1
    $* <'+a -b'  == 1
    $* <'+a -!x' == 1
    $* <'+a &x'  == 1
    $* <'+a &!b' == 1

    $* <'+a -( +b )'                  == 1
    $* <'+a -!( +x )'                 == 1
    $* <'+a &( +x )'                  == 1
    $* <'+a &!( +b )'                 == 1
    $* <'+a -c +( +x )'               == 1
    $* <'+a -c +!( +b )'              == 1
    $* <'+a -( +x +b )'               == 1
    $* <'+a &( +b -c +( +a +b ) &x )' == 1

    $* <'x : +a' == 1
    $* <'a : -c' == 1
  }

  : empty-class-list
  :
  {
    $* <'+a' == 1
  }


  : base
  :
  {
    test.arguments += a:x b:y c

    $* <'+z' == 1
  }
}