v2 / vlib / v / tests / comptime / comptime_call_tmpl_composed_path_test.v
32 lines · 27 sloc · 963 bytes · 21c1aba56103052ce5f62293c51659b8185155db
Raw
1import os
2
3const tmpl_dir_name = 'templates'
4const tmpl_file_name = 'comptime_call_tmpl_composed_path_test.txt'
5const tmpl_plus_path = tmpl_dir_name + '/' + tmpl_file_name
6const tmpl_separator_path = tmpl_dir_name + os.path_separator + tmpl_file_name
7const tmpl_joined_path = os.join_path(tmpl_dir_name, tmpl_file_name)
8
9fn test_comptime_tmpl_resolves_plus_path_const() {
10 value := 'plus'
11 rendered := $tmpl(tmpl_plus_path)
12 assert rendered.contains(value)
13}
14
15fn test_comptime_tmpl_resolves_path_separator_const() {
16 value := 'separator'
17 rendered := $tmpl(tmpl_separator_path)
18 assert rendered.contains(value)
19}
20
21fn test_comptime_tmpl_resolves_join_path_const() {
22 value := 'joined const'
23 rendered := $tmpl(tmpl_joined_path)
24 assert rendered.contains(value)
25}
26
27fn test_comptime_tmpl_resolves_join_path_variable() {
28 value := 'joined var'
29 tmpl_path := os.join_path(tmpl_dir_name, tmpl_file_name)
30 rendered := $tmpl(tmpl_path)
31 assert rendered.contains(value)
32}
33