mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
43 lines
953 B
V
43 lines
953 B
V
import vmod
|
|
|
|
fn test_from_file() {
|
|
data := vmod.from_file('./v.mod') or {
|
|
panic(err)
|
|
}
|
|
assert data.name == 'V'
|
|
assert data.description == 'The V programming language.'
|
|
assert data.version == '0.1.27'
|
|
assert data.dependencies.len == 0
|
|
}
|
|
|
|
fn test_decode() {
|
|
content := "
|
|
Module {
|
|
name: \'foobar\',
|
|
description: \'Just a sample module\'
|
|
version: \'0.2.0\',
|
|
repo_url: \'https://gitlab.com\',
|
|
author: \'Fooz Bar\',
|
|
license: \'GPL-2.0\',
|
|
dependencies: [\'hello\'],
|
|
test: \'foo\'
|
|
}
|
|
"
|
|
data := vmod.decode(content) or {
|
|
println(err)
|
|
exit(1)
|
|
}
|
|
assert data.name == 'foobar'
|
|
assert data.version == '0.2.0'
|
|
assert data.description == 'Just a sample module'
|
|
assert data.repo_url == 'https://gitlab.com'
|
|
assert data.author == 'Fooz Bar'
|
|
assert data.license == 'GPL-2.0'
|
|
assert data.dependencies[0] == 'hello'
|
|
assert data.unknown['test'][0] == 'foo'
|
|
vmod.decode('') or {
|
|
assert err == 'vmod: no content.'
|
|
exit(0)
|
|
}
|
|
}
|