v.build_constraint: support // vtest build: false and // vtest build: true too; add tests

This commit is contained in:
Delyan Angelov 2025-03-12 15:35:06 +02:00
parent acfa088b60
commit d970a8fce2
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
2 changed files with 16 additions and 0 deletions

View File

@ -15,6 +15,21 @@ fn test_eval_define() {
assert !benv.is_define('xyz')
}
fn test_eval_true() {
assert benv.eval('true')!
}
fn test_eval_false() {
assert !benv.eval('false')!
}
fn test_eval_comment() {
assert benv.eval('true // some comment')!
assert benv.eval(' true// another comment ...')!
assert !benv.eval('false // some comment')!
assert !benv.eval(' false// another comment ...')!
}
fn test_eval_platforms_and_compilers() {
assert benv.eval('tinyc')!
assert benv.eval(' tinyc')!

View File

@ -13,6 +13,7 @@ pub mut:
// `defines` is a list of the user defines, for example: ['abc', 'gcboehm_opt', 'gg_record', 'show_fps']
pub fn new_environment(facts []string, defines []string) &Environment {
mut b := &Environment{}
b.facts['true'] = true
for f in facts {
b.facts[f] = true
}