2020-02-16 14:42:28 +03:00
|
|
|
import os.cmdline
|
|
|
|
|
|
|
|
fn test_options() {
|
|
|
|
args := ['v', '-d', 'aa', '-d', 'bb', '-d', 'cc']
|
|
|
|
ret := cmdline.options(args, '-d')
|
2021-08-09 15:42:31 +03:00
|
|
|
assert ret == ['aa', 'bb', 'cc']
|
2020-02-16 14:42:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
fn test_option() {
|
|
|
|
args := ['v', '-d', 'aa']
|
|
|
|
ret := cmdline.option(args, '-d', '')
|
|
|
|
assert ret == 'aa'
|
|
|
|
}
|
|
|
|
|
|
|
|
fn test_options_before() {
|
|
|
|
args := ['-stat', 'test', 'aaa.v']
|
|
|
|
ret := cmdline.options_before(args, ['test'])
|
2021-08-09 15:42:31 +03:00
|
|
|
assert ret == ['-stat']
|
2020-02-16 14:42:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
fn test_options_after() {
|
|
|
|
args := ['-stat', 'test', 'aaa.v']
|
|
|
|
ret := cmdline.options_after(args, ['test'])
|
2021-08-09 15:42:31 +03:00
|
|
|
assert ret == ['aaa.v']
|
2020-02-16 14:42:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
fn test_only_non_options() {
|
|
|
|
args := ['-d', 'aa', '--help', 'bb']
|
|
|
|
ret := cmdline.only_non_options(args)
|
2021-08-09 15:42:31 +03:00
|
|
|
assert ret == ['aa', 'bb']
|
2020-02-16 14:42:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
fn test_only_options() {
|
|
|
|
args := ['-d', 'aa', '--help', 'bb']
|
|
|
|
ret := cmdline.only_options(args)
|
2021-08-09 15:42:31 +03:00
|
|
|
assert ret == ['-d', '--help']
|
2020-02-16 14:42:28 +03:00
|
|
|
}
|