diff --git a/vlib/v/build_constraint/constraint_test.v b/vlib/v/build_constraint/constraint_test.v index cc5f330de1..c7e5b066d8 100644 --- a/vlib/v/build_constraint/constraint_test.v +++ b/vlib/v/build_constraint/constraint_test.v @@ -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')! diff --git a/vlib/v/build_constraint/public.v b/vlib/v/build_constraint/public.v index bdf1db94c6..bc9eed6aa4 100644 --- a/vlib/v/build_constraint/public.v +++ b/vlib/v/build_constraint/public.v @@ -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 }