Skip to content

Commit c2e2aac

Browse files
committed
tests: use os.vtmp_dir() in autofree_toml.vv, so it can be cleaned up automatically; simplify the code
1 parent 97145ca commit c2e2aac

1 file changed

Lines changed: 5 additions & 11 deletions

File tree

‎vlib/v/gen/c/testdata/autofree_toml.vv‎

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,8 @@
22
import toml
33
import os
44

5-
fn main() {
6-
config_fname := 'config.toml'
7-
tab_title := 'test tab title'
8-
if !os.exists(config_fname) {
9-
mut f := os.create(config_fname) or { panic(err) }
10-
f.writeln('tab_title = "${tab_title}"') or { panic(err) }
11-
f.close()
12-
}
13-
doc := toml.parse_file(config_fname) or { panic(err) }
14-
assert doc.value('tab_title').string() == tab_title
15-
}
5+
config_fname := os.join_path(os.vtmp_dir(), 'config.toml')
6+
tab_title := 'test tab title'
7+
os.write_file(config_fname, 'tab_title = "${tab_title}"')!
8+
doc := toml.parse_file(config_fname)!
9+
assert doc.value('tab_title').string() == tab_title

0 commit comments

Comments
 (0)