mirror of
https://github.com/vlang/v.git
synced 2025-09-23 04:18:48 -04:00
tests: use os.vtmp_dir() in autofree_toml.vv, so it can be cleaned up automatically; simplify the code
This commit is contained in:
parent
97145ca3a8
commit
c2e2aac0c9
16
vlib/v/gen/c/testdata/autofree_toml.vv
vendored
16
vlib/v/gen/c/testdata/autofree_toml.vv
vendored
@ -2,14 +2,8 @@
|
||||
import toml
|
||||
import os
|
||||
|
||||
fn main() {
|
||||
config_fname := 'config.toml'
|
||||
tab_title := 'test tab title'
|
||||
if !os.exists(config_fname) {
|
||||
mut f := os.create(config_fname) or { panic(err) }
|
||||
f.writeln('tab_title = "${tab_title}"') or { panic(err) }
|
||||
f.close()
|
||||
}
|
||||
doc := toml.parse_file(config_fname) or { panic(err) }
|
||||
assert doc.value('tab_title').string() == tab_title
|
||||
}
|
||||
config_fname := os.join_path(os.vtmp_dir(), 'config.toml')
|
||||
tab_title := 'test tab title'
|
||||
os.write_file(config_fname, 'tab_title = "${tab_title}"')!
|
||||
doc := toml.parse_file(config_fname)!
|
||||
assert doc.value('tab_title').string() == tab_title
|
||||
|
Loading…
x
Reference in New Issue
Block a user