cgen: fix double escaping \n in @VMOD_FILE expansion
parent
7212b2eff2
commit
6e76d5d1db
|
@ -110,7 +110,7 @@ fn cgen_attrs(attrs []table.Attr) []string {
|
|||
|
||||
fn (mut g Gen) comp_at(node ast.AtExpr) {
|
||||
if node.kind == .vmod_file {
|
||||
val := cnewlines(node.val.replace('\r', '')).replace('\\', '\\\\')
|
||||
val := cnewlines(node.val.replace('\r', ''))
|
||||
g.write('_SLIT("$val")')
|
||||
} else {
|
||||
val := node.val.replace('\\', '\\\\')
|
||||
|
|
|
@ -3,9 +3,7 @@ import os
|
|||
|
||||
fn test_from_file() {
|
||||
os.chdir(os.dir(os.getenv('VEXE')))
|
||||
data := vmod.from_file('./v.mod') or {
|
||||
panic(err)
|
||||
}
|
||||
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.30'
|
||||
|
@ -42,3 +40,10 @@ fn test_decode() {
|
|||
exit(0)
|
||||
}
|
||||
}
|
||||
|
||||
fn test_decode_with_comptime_vmod_file() {
|
||||
mod := vmod.decode(@VMOD_FILE) or { panic('Error decoding v.mod') }
|
||||
assert mod.name == 'V'
|
||||
assert mod.repo_url == 'https://github.com/vlang/v'
|
||||
assert mod.license == 'MIT'
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue