1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

cgen: fix os.args initialization, so that const x = os.args[0] works

This commit is contained in:
Delyan Angelov
2021-01-10 14:31:20 +02:00
parent 0081e5740d
commit 722a603222
4 changed files with 51 additions and 40 deletions

View File

@@ -7,6 +7,10 @@ const (
tfolder = os.join_path(os.temp_dir(), 'v', 'tests', 'os_test')
)
// os.args has to be *already initialized* with the program's argc/argv at this point
// thus it can be used for other consts too:
const args_at_start = os.args.clone()
fn testsuite_begin() {
eprintln('testsuite_begin, tfolder = $tfolder')
os.rmdir_all(tfolder)
@@ -14,6 +18,9 @@ fn testsuite_begin() {
os.mkdir_all(tfolder)
os.chdir(tfolder)
assert os.is_dir(tfolder)
// println('args_at_start: $args_at_start')
assert args_at_start.len > 0
assert args_at_start == os.args
}
fn testsuite_end() {