Skip to content

Commit d970a8f

Browse files
committed
v.build_constraint: support // vtest build: false and // vtest build: true too; add tests
1 parent acfa088 commit d970a8f

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

vlib/v/build_constraint/constraint_test.v

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,21 @@ fn test_eval_define() {
1515
assert !benv.is_define('xyz')
1616
}
1717

18+
fn test_eval_true() {
19+
assert benv.eval('true')!
20+
}
21+
22+
fn test_eval_false() {
23+
assert !benv.eval('false')!
24+
}
25+
26+
fn test_eval_comment() {
27+
assert benv.eval('true // some comment')!
28+
assert benv.eval(' true// another comment ...')!
29+
assert !benv.eval('false // some comment')!
30+
assert !benv.eval(' false// another comment ...')!
31+
}
32+
1833
fn test_eval_platforms_and_compilers() {
1934
assert benv.eval('tinyc')!
2035
assert benv.eval(' tinyc')!

vlib/v/build_constraint/public.v

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ pub mut:
1313
// `defines` is a list of the user defines, for example: ['abc', 'gcboehm_opt', 'gg_record', 'show_fps']
1414
pub fn new_environment(facts []string, defines []string) &Environment {
1515
mut b := &Environment{}
16+
b.facts['true'] = true
1617
for f in facts {
1718
b.facts[f] = true
1819
}

0 commit comments

Comments
 (0)