vpac / src / style_test.v
24 lines · 20 sloc · 611 bytes · 3609dfbd82867dc1034a443f8f9ced529ddbbedd
Raw
1module main
2
3import term
4
5fn test_color_flag() {
6 old := color_flag
7 defer { color_flag = old }
8
9 color_flag = 'always'
10 assert color_on(false) && color_on(true)
11 assert heading('x') == term.bold('x')
12 assert erole('old', 'x') == term.red('x')
13 assert warning('w').contains('\x1b[')
14 assert q_no_yes() == '[y/' + term.bold('N') + ']'
15
16 color_flag = 'never'
17 assert !color_on(false) && !color_on(true)
18 assert heading('x') == 'x'
19 assert version_style('1.0-1') == '1.0-1'
20 assert erole('old', 'x') == 'x'
21 assert warning('w') == 'warning: w'
22 assert q_yes_no() == '[Y/n]'
23 assert error_text('e') == 'error: e'
24}
25