mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cgen: fix double escaping \n in @VMOD_FILE expansion
This commit is contained in:
@@ -110,7 +110,7 @@ fn cgen_attrs(attrs []table.Attr) []string {
|
|||||||
|
|
||||||
fn (mut g Gen) comp_at(node ast.AtExpr) {
|
fn (mut g Gen) comp_at(node ast.AtExpr) {
|
||||||
if node.kind == .vmod_file {
|
if node.kind == .vmod_file {
|
||||||
val := cnewlines(node.val.replace('\r', '')).replace('\\', '\\\\')
|
val := cnewlines(node.val.replace('\r', ''))
|
||||||
g.write('_SLIT("$val")')
|
g.write('_SLIT("$val")')
|
||||||
} else {
|
} else {
|
||||||
val := node.val.replace('\\', '\\\\')
|
val := node.val.replace('\\', '\\\\')
|
||||||
|
@@ -3,9 +3,7 @@ import os
|
|||||||
|
|
||||||
fn test_from_file() {
|
fn test_from_file() {
|
||||||
os.chdir(os.dir(os.getenv('VEXE')))
|
os.chdir(os.dir(os.getenv('VEXE')))
|
||||||
data := vmod.from_file('./v.mod') or {
|
data := vmod.from_file('./v.mod') or { panic(err) }
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
assert data.name == 'V'
|
assert data.name == 'V'
|
||||||
assert data.description == 'The V programming language.'
|
assert data.description == 'The V programming language.'
|
||||||
assert data.version == '0.1.30'
|
assert data.version == '0.1.30'
|
||||||
@@ -42,3 +40,10 @@ fn test_decode() {
|
|||||||
exit(0)
|
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'
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user