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
147
148
149
150
151
152
153
|
project('dolphin option', 'c')
d = disabler()
full_path = d.full_path()
assert(is_disabler(full_path), 'Method call is not a disabler')
d2 = dependency(d)
d3 = (d == d2)
d4 = d + 0
d5 = d2 or true
set_variable('d6', disabler())
has_not_changed = false
if is_disabler(d)
has_not_changed = true
else
has_not_changed = true
endif
assert(has_not_changed, 'Disabler has changed.')
assert(is_disabler(d), 'Disabler was not identified correctly.')
assert(is_disabler(d2), 'Function laundered disabler was not identified correctly.')
assert(is_disabler(d3), 'Disabler comparison should yield disabler.')
assert(is_disabler(d4), 'Disabler addition should yield disabler.')
assert(is_disabler(d5), 'Disabler logic op should yield disabler.')
assert(is_disabler(d6), 'set_variable with a disabler should set variable to disabler.')
assert(d, 'Disabler did not cause this to be skipped.')
assert(d2, 'Function laundered disabler did not cause this to be skipped.')
assert(d3, 'Disabler comparison should yield disabler and thus this would not be called.')
assert(d4, 'Disabler addition should yield disabler and thus this would not be called.')
assert(d5, 'Disabler logic op should yield disabler and thus this would not be called.')
assert(d6, 'set_variable with a disabler did not cause this to be skipped.')
number = 0
if d
number = 1
else
number = 2
endif
has_not_changed = false
if is_disabler(number)
has_not_changed = true
else
has_not_changed = true
endif
assert(has_not_changed, 'Number has changed.')
assert(not is_disabler(number), 'Number should not be a disabler.')
assert(number == 0, 'Plain if handled incorrectly, value should be 0 but is @0@'.format(number))
if d.found()
number = 1
else
number = 2
endif
assert(number == 2, 'If found handled incorrectly, value should be 2 but is @0@'.format(number))
dep = dependency('notfounddep', required : false, disabler : true)
app = executable('myapp', 'notfound.c', dependencies : [dep])
assert(is_disabler(app), 'App is not a disabler.')
app = executable('myapp', 'notfound.c', dependencies : [[dep]])
assert(is_disabler(app), 'App is not a disabler.')
cc = meson.get_compiler('c')
dep = cc.find_library('notfounddep', required : false, disabler : true)
app = executable('myapp', 'notfound.c', dependencies : [dep])
assert(is_disabler(app), 'App is not a disabler.')
dep = find_program('donotfindme', required : false, disabler : true)
app = executable('myapp', 'notfound.c', dependencies : [dep])
assert(is_disabler(app), 'App is not a disabler.')
has_not_changed = false
if is_disabler(app)
has_not_changed = true
else
has_not_changed = true
endif
assert(has_not_changed, 'App has changed.')
assert(not is_disabler(is_variable('d6')), 'is_variable should not return a disabler')
assert(is_variable('d6'), 'is_variable for a disabler should return true')
if_is_not_disabled = false
if is_variable('d6')
if_is_not_disabled = true
else
if_is_not_disabled = true
endif
assert(if_is_not_disabled, 'Disabler in is_variable should not skip blocks')
get_d = get_variable('d6')
assert(is_disabler(get_d), 'get_variable should yield a disabler')
get_fallback_d = get_variable('nonexistant', disabler())
assert(is_disabler(get_fallback_d), 'get_variable fallback should yield a disabler')
var_true = true
get_no_fallback_d = get_variable('var_true', disabler())
assert(not is_disabler(get_no_fallback_d), 'get_variable should not fallback to disabler')
assert(get_no_fallback_d, 'get_variable should yield true')
assert(is_disabler(get_variable(disabler())), 'get_variable should yield a disabler')
assert(is_disabler(get_variable(disabler(), var_true)), 'get_variable should yield a disabler')
if_is_disabled = true
if disabler()
if_is_disabled = false
else
if_is_disabled = false
endif
assert(if_is_disabled, 'Disabler in "if condition" must skip both blocks')
if not disabler()
if_is_disabled = false
else
if_is_disabled = false
endif
assert(if_is_disabled, 'Disabler in "if not condition" must skip both blocks')
if disabler() == 1
if_is_disabled = false
else
if_is_disabled = false
endif
assert(if_is_disabled, 'Disabler in "if a==b" must skip both blocks')
loops = 0
disablers = 0
foreach i : [true, disabler(), true]
loops += 1
if is_disabler(i)
disablers += 1
endif
endforeach
assert(loops == 3, 'Disabler in foreach array')
assert(disablers == 1, 'Disabler in foreach array')
loops = 0
disablers = 0
foreach k, i : {'a': true, 'b': disabler(), 'c': true}
loops += 1
if is_disabler(i)
disablers += 1
endif
endforeach
assert(loops == 3, 'Disabler in foreach dict')
assert(disablers == 1, 'Disabler in foreach dict')
|