v2: fixes for most of vlib/builtin/map_test.v .
parent
07c53b1b70
commit
6b9bf8cbf7
|
@ -73,8 +73,8 @@ fn test_string_map() {
|
||||||
fn test_large_map() {
|
fn test_large_map() {
|
||||||
//ticks := time.ticks()
|
//ticks := time.ticks()
|
||||||
mut nums := map[string]int
|
mut nums := map[string]int
|
||||||
N := 30 * 1000
|
n := 30 * 1000
|
||||||
for i in 0..N {
|
for i in 0..n {
|
||||||
key := i.str()
|
key := i.str()
|
||||||
nums[key] = i
|
nums[key] = i
|
||||||
}
|
}
|
||||||
|
@ -166,7 +166,8 @@ fn mut_map(m mut map[string]int) {
|
||||||
fn test_mut_arg() {
|
fn test_mut_arg() {
|
||||||
mut m := map[string]int
|
mut m := map[string]int
|
||||||
mut_map(mut m)
|
mut_map(mut m)
|
||||||
assert m['a'] == 10
|
a := m['a']
|
||||||
|
assert a == 10
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_delete() {
|
fn test_delete() {
|
||||||
|
@ -175,8 +176,8 @@ fn test_delete() {
|
||||||
m['two'] = 2
|
m['two'] = 2
|
||||||
println(m['two']) // => "2"
|
println(m['two']) // => "2"
|
||||||
m.delete('two')
|
m.delete('two')
|
||||||
println(m['two']) // => 0
|
println(m['two'].str()) // => 0
|
||||||
assert 'two' in m == false
|
assert ('two' in m) == false
|
||||||
println('two' in m) // => true, on Linux and Windows <-- wrong !
|
println('two' in m) // => true, on Linux and Windows <-- wrong !
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,4 +206,3 @@ fn test_delete_size() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -337,6 +337,7 @@ pub:
|
||||||
index Expr // [0], [start..end] etc
|
index Expr // [0], [start..end] etc
|
||||||
mut:
|
mut:
|
||||||
container_type table.Type // array, map, fixed array
|
container_type table.Type // array, map, fixed array
|
||||||
|
is_setter bool
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct IfExpr {
|
pub struct IfExpr {
|
||||||
|
|
|
@ -77,6 +77,9 @@ pub fn (x Expr) str() string {
|
||||||
ParExpr {
|
ParExpr {
|
||||||
return it.expr.str()
|
return it.expr.str()
|
||||||
}
|
}
|
||||||
|
IndexExpr {
|
||||||
|
return '${it.left.str()}[${it.index.str()}]'
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
return '[unhandled expr type ${typeof(x)}]'
|
return '[unhandled expr type ${typeof(x)}]'
|
||||||
}
|
}
|
||||||
|
|
|
@ -1682,7 +1682,7 @@ fn (g mut Gen) index_expr(node ast.IndexExpr) {
|
||||||
}
|
}
|
||||||
else {}
|
else {}
|
||||||
}
|
}
|
||||||
if g.is_assign_lhs && !is_selector {
|
if g.is_assign_lhs && !is_selector && node.is_setter {
|
||||||
g.is_array_set = true
|
g.is_array_set = true
|
||||||
g.write('array_set(&')
|
g.write('array_set(&')
|
||||||
g.expr(node.left)
|
g.expr(node.left)
|
||||||
|
|
|
@ -436,6 +436,13 @@ pub fn (p mut Parser) assign_expr(left ast.Expr) ast.AssignExpr {
|
||||||
op := p.tok.kind
|
op := p.tok.kind
|
||||||
p.next()
|
p.next()
|
||||||
val := p.expr(0)
|
val := p.expr(0)
|
||||||
|
match left {
|
||||||
|
ast.IndexExpr {
|
||||||
|
//it.mark_as_setter()
|
||||||
|
it.is_setter = true
|
||||||
|
}
|
||||||
|
else{}
|
||||||
|
}
|
||||||
node := ast.AssignExpr{
|
node := ast.AssignExpr{
|
||||||
left: left
|
left: left
|
||||||
val: val
|
val: val
|
||||||
|
|
Loading…
Reference in New Issue