Debian Codegraph @

test cases/common/158 disabler/meson.build

raw
1 project('dolphin option', 'c')
2
3 d = disabler()
4
5 full_path = d.full_path()
6 assert(is_disabler(full_path), 'Method call is not a disabler')
7
8 d2 = dependency(d)
9 d3 = (d == d2)
10 d4 = d + 0
11 d5 = d2 or true
12 set_variable('d6', disabler())
13
14 has_not_changed = false
15 if is_disabler(d)
16 has_not_changed = true
17 else
18 has_not_changed = true
19 endif
20 assert(has_not_changed, 'Disabler has changed.')
21
22 assert(is_disabler(d), 'Disabler was not identified correctly.')
23 assert(is_disabler(d2), 'Function laundered disabler was not identified correctly.')
24 assert(is_disabler(d3), 'Disabler comparison should yield disabler.')
25 assert(is_disabler(d4), 'Disabler addition should yield disabler.')
26 assert(is_disabler(d5), 'Disabler logic op should yield disabler.')
27 assert(is_disabler(d6), 'set_variable with a disabler should set variable to disabler.')
28
29 assert(d, 'Disabler did not cause this to be skipped.')
30 assert(d2, 'Function laundered disabler did not cause this to be skipped.')
31 assert(d3, 'Disabler comparison should yield disabler and thus this would not be called.')
32 assert(d4, 'Disabler addition should yield disabler and thus this would not be called.')
33 assert(d5, 'Disabler logic op should yield disabler and thus this would not be called.')
34 assert(d6, 'set_variable with a disabler did not cause this to be skipped.')
35
36 number = 0
37
38 if d
39 number = 1
40 else
41 number = 2
42 endif
43
44 has_not_changed = false
45 if is_disabler(number)
46 has_not_changed = true
47 else
48 has_not_changed = true
49 endif
50 assert(has_not_changed, 'Number has changed.')
51
52 assert(not is_disabler(number), 'Number should not be a disabler.')
53 assert(number == 0, 'Plain if handled incorrectly, value should be 0 but is @0@'.format(number))
54
55 if d.found()
56 number = 1
57 else
58 number = 2
59 endif
60
61 assert(number == 2, 'If found handled incorrectly, value should be 2 but is @0@'.format(number))
62
63 dep = dependency('notfounddep', required : false, disabler : true)
64 app = executable('myapp', 'notfound.c', dependencies : [dep])
65 assert(is_disabler(app), 'App is not a disabler.')
66 app = executable('myapp', 'notfound.c', dependencies : [[dep]])
67 assert(is_disabler(app), 'App is not a disabler.')
68
69 cc = meson.get_compiler('c')
70 dep = cc.find_library('notfounddep', required : false, disabler : true)
71 app = executable('myapp', 'notfound.c', dependencies : [dep])
72 assert(is_disabler(app), 'App is not a disabler.')
73
74 dep = find_program('donotfindme', required : false, disabler : true)
75 app = executable('myapp', 'notfound.c', dependencies : [dep])
76 assert(is_disabler(app), 'App is not a disabler.')
77
78 has_not_changed = false
79 if is_disabler(app)
80 has_not_changed = true
81 else
82 has_not_changed = true
83 endif
84 assert(has_not_changed, 'App has changed.')
85
86 assert(not is_disabler(is_variable('d6')), 'is_variable should not return a disabler')
87 assert(is_variable('d6'), 'is_variable for a disabler should return true')
88
89 if_is_not_disabled = false
90 if is_variable('d6')
91 if_is_not_disabled = true
92 else
93 if_is_not_disabled = true
94 endif
95 assert(if_is_not_disabled, 'Disabler in is_variable should not skip blocks')
96
97 get_d = get_variable('d6')
98 assert(is_disabler(get_d), 'get_variable should yield a disabler')
99
100 get_fallback_d = get_variable('nonexistent', disabler())
101 assert(is_disabler(get_fallback_d), 'get_variable fallback should yield a disabler')
102
103 var_true = true
104 get_no_fallback_d = get_variable('var_true', disabler())
105 assert(not is_disabler(get_no_fallback_d), 'get_variable should not fallback to disabler')
106 assert(get_no_fallback_d, 'get_variable should yield true')
107
108 assert(is_disabler(get_variable(disabler())), 'get_variable should yield a disabler')
109 assert(is_disabler(get_variable(disabler(), var_true)), 'get_variable should yield a disabler')
110
111 if_is_disabled = true
112 if disabler()
113 if_is_disabled = false
114 else
115 if_is_disabled = false
116 endif
117 assert(if_is_disabled, 'Disabler in "if condition" must skip both blocks')
118
119 if not disabler()
120 if_is_disabled = false
121 else
122 if_is_disabled = false
123 endif
124 assert(if_is_disabled, 'Disabler in "if not condition" must skip both blocks')
125
126 if disabler() == 1
127 if_is_disabled = false
128 else
129 if_is_disabled = false
130 endif
131 assert(if_is_disabled, 'Disabler in "if a==b" must skip both blocks')
132
133 loops = 0
134 disablers = 0
135 foreach i : [true, disabler(), true]
136 loops += 1
137 if is_disabler(i)
138 disablers += 1
139 endif
140 endforeach
141 assert(loops == 3, 'Disabler in foreach array')
142 assert(disablers == 1, 'Disabler in foreach array')
143
144 loops = 0
145 disablers = 0
146 foreach k, i : {'a': true, 'b': disabler(), 'c': true}
147 loops += 1
148 if is_disabler(i)
149 disablers += 1
150 endif
151 endforeach
152 assert(loops == 3, 'Disabler in foreach dict')
153 assert(disablers == 1, 'Disabler in foreach dict')