diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-07-04 13:37:23 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-07-04 13:37:23 -0400 |
| commit | 22063462a90b5c290f5f71319b259fca80da8097 (patch) | |
| tree | 67d403f893415de9202477608ae9972b9171df88 /test | |
| parent | dc1616a3bf7d075e0b50f783313ea6a5b1076fb4 (diff) | |
Add __length and __negative metamethods
Diffstat (limited to 'test')
| -rw-r--r-- | test/metamethods.tm | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/metamethods.tm b/test/metamethods.tm index 97d9e5eb..26a5abd6 100644 --- a/test/metamethods.tm +++ b/test/metamethods.tm @@ -17,6 +17,12 @@ struct Vec2(x,y:Int): func __mul4(a,b:Vec2; inline)->Vec2: return Vec2(a.x*b.x, a.y*b.y) + func __negative(v:Vec2; inline)->Vec2: + return Vec2(-v.x, -v.y) + + func __length(v:Vec2; inline)->Int: + return 2 + func main(): >> x := Vec2(10, 20) >> y := Vec2(100, 200) @@ -36,3 +42,10 @@ func main(): = Vec2(x=11, y=22) >> x *= Vec2(10, -1) = Vec2(x=110, y=-22) + + >> x = Vec2(1, 2) + >> -x + = Vec2(x=-1, y=-2) + >> #x + = 2 + |
