mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
tests: add test for s.$method() with T.methods (#8451)
This commit is contained in:
parent
c5e7956eb5
commit
9c2bd24b4f
@ -1,7 +1,7 @@
|
|||||||
struct Test {}
|
struct Test {}
|
||||||
|
|
||||||
fn (test Test) v() {
|
fn (test Test) v() {
|
||||||
println('in v()')
|
println('Test.v()')
|
||||||
}
|
}
|
||||||
fn (test Test) i() int {
|
fn (test Test) i() int {
|
||||||
return 4
|
return 4
|
||||||
@ -13,7 +13,7 @@ fn (test Test) s2() string {
|
|||||||
return 'Two'
|
return 'Two'
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_call() {
|
fn test_string_identifier() {
|
||||||
test := Test{}
|
test := Test{}
|
||||||
sv := 'v'
|
sv := 'v'
|
||||||
test.$sv()
|
test.$sv()
|
||||||
@ -24,3 +24,29 @@ fn test_call() {
|
|||||||
rs := test.$ss()
|
rs := test.$ss()
|
||||||
assert rs == 'test'
|
assert rs == 'test'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn test_for_methods() {
|
||||||
|
test := Test{}
|
||||||
|
mut r := ''
|
||||||
|
$for method in Test.methods {
|
||||||
|
// currently the checker thinks all $method calls return string
|
||||||
|
$if method.return_type is string {
|
||||||
|
//~ $if method.name == 's' {println('yes')}
|
||||||
|
v := test.$method()
|
||||||
|
r += v.str()
|
||||||
|
}
|
||||||
|
$else $if method.return_type is int {
|
||||||
|
// TODO
|
||||||
|
//v := test.$method()
|
||||||
|
v := '?'
|
||||||
|
r += v.str()
|
||||||
|
assert method.name == 'i'
|
||||||
|
}
|
||||||
|
$else {
|
||||||
|
// no return type
|
||||||
|
test.$method()
|
||||||
|
assert method.name == 'v'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assert r == '?testTwo'
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user