mirror of
https://github.com/vlang/v.git
synced 2025-09-19 04:17:46 -04:00
cgen: fix showing the expression, as literal value, in case of assert s[x..y] == "literal"
(fix #24103) (#24105)
This commit is contained in:
parent
a59b717daa
commit
42ac6885df
@ -207,12 +207,8 @@ fn (mut g Gen) gen_assert_single_expr(expr ast.Expr, typ ast.Type) {
|
|||||||
g.write(ctoslit(expr_str))
|
g.write(ctoslit(expr_str))
|
||||||
}
|
}
|
||||||
ast.IndexExpr {
|
ast.IndexExpr {
|
||||||
if expr.index is ast.RangeExpr {
|
|
||||||
g.write(ctoslit(expr_str))
|
|
||||||
} else {
|
|
||||||
g.gen_expr_to_string(expr, typ)
|
g.gen_expr_to_string(expr, typ)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
ast.PrefixExpr {
|
ast.PrefixExpr {
|
||||||
if expr.right is ast.CastExpr {
|
if expr.right is ast.CastExpr {
|
||||||
// TODO: remove this check;
|
// TODO: remove this check;
|
||||||
|
@ -3,3 +3,8 @@ vlib/v/tests/skip_unused/assert_works_test.vv:2: fn test_abc
|
|||||||
Left value (len: 3): `abc`
|
Left value (len: 3): `abc`
|
||||||
Right value (len: 3): `xyz`
|
Right value (len: 3): `xyz`
|
||||||
|
|
||||||
|
vlib/v/tests/skip_unused/assert_works_test.vv:7: fn test_index_expr
|
||||||
|
> assert example_string[1 .. 4] == 'abcdef'
|
||||||
|
Left value (len: 3): `his`
|
||||||
|
Right value (len: 6): `abcdef`
|
||||||
|
|
||||||
|
@ -3,3 +3,8 @@ vlib/v/tests/skip_unused/assert_works_test.vv:2: fn test_abc
|
|||||||
Left value (len: 3): `abc`
|
Left value (len: 3): `abc`
|
||||||
Right value (len: 3): `xyz`
|
Right value (len: 3): `xyz`
|
||||||
|
|
||||||
|
vlib/v/tests/skip_unused/assert_works_test.vv:7: fn test_index_expr
|
||||||
|
> assert example_string[1 .. 4] == 'abcdef'
|
||||||
|
Left value (len: 3): `his`
|
||||||
|
Right value (len: 6): `abcdef`
|
||||||
|
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
fn test_abc() {
|
fn test_abc() {
|
||||||
assert 'abc' == 'xyz'
|
assert 'abc' == 'xyz'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn test_index_expr() {
|
||||||
|
example_string := 'This is an example string'
|
||||||
|
assert example_string[1..4] == 'abcdef'
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user