-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
checker: check alias of array op overloading and fix op overloading (fix
- Loading branch information
Showing
4 changed files
with
71 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
vlib/v/tests/builtin_arrays/array_of_alias_op_overload_test.v
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
type Array1 = []u8 | ||
|
||
type Array2 = []u8 | ||
|
||
fn (a Array2) == (other Array2) bool { | ||
return a[0] == other[0] | ||
} | ||
|
||
fn (a Array2) < (other Array2) bool { | ||
return a[0] < other[0] | ||
} | ||
|
||
fn test_array_of_alias_op_overload() { | ||
a := Array1([u8(127), 0, 0, 1]) | ||
b := Array1([u8(127), 0, 0, 1]) | ||
|
||
c := Array2([u8(127), 0, 0, 1]) | ||
d := Array2([u8(127), 0, 0, 1]) | ||
|
||
ret0 := a == b | ||
println(ret0) | ||
assert ret0 | ||
|
||
ret1 := c == d | ||
println(ret1) | ||
assert ret1 | ||
|
||
ret2 := c < d | ||
println(ret2) | ||
assert !ret2 | ||
} |