diff options
Diffstat (limited to 'testes/events.lua')
| -rw-r--r-- | testes/events.lua | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/testes/events.lua b/testes/events.lua index cf68d1e9..7fb54c9a 100644 --- a/testes/events.lua +++ b/testes/events.lua | |||
| @@ -217,9 +217,16 @@ t.__le = function (a,b,c) | |||
| 217 | return a<=b, "dummy" | 217 | return a<=b, "dummy" |
| 218 | end | 218 | end |
| 219 | 219 | ||
| 220 | t.__eq = function (a,b,c) | ||
| 221 | assert(c == nil) | ||
| 222 | if type(a) == 'table' then a = a.x end | ||
| 223 | if type(b) == 'table' then b = b.x end | ||
| 224 | return a == b, "dummy" | ||
| 225 | end | ||
| 226 | |||
| 220 | function Op(x) return setmetatable({x=x}, t) end | 227 | function Op(x) return setmetatable({x=x}, t) end |
| 221 | 228 | ||
| 222 | local function test () | 229 | local function test (a, b, c) |
| 223 | assert(not(Op(1)<Op(1)) and (Op(1)<Op(2)) and not(Op(2)<Op(1))) | 230 | assert(not(Op(1)<Op(1)) and (Op(1)<Op(2)) and not(Op(2)<Op(1))) |
| 224 | assert(not(1 < Op(1)) and (Op(1) < 2) and not(2 < Op(1))) | 231 | assert(not(1 < Op(1)) and (Op(1) < 2) and not(2 < Op(1))) |
| 225 | assert(not(Op('a')<Op('a')) and (Op('a')<Op('b')) and not(Op('b')<Op('a'))) | 232 | assert(not(Op('a')<Op('a')) and (Op('a')<Op('b')) and not(Op('b')<Op('a'))) |
| @@ -232,9 +239,13 @@ local function test () | |||
| 232 | assert((1 >= Op(1)) and not(1 >= Op(2)) and (Op(2) >= 1)) | 239 | assert((1 >= Op(1)) and not(1 >= Op(2)) and (Op(2) >= 1)) |
| 233 | assert((Op('a')>=Op('a')) and not(Op('a')>=Op('b')) and (Op('b')>=Op('a'))) | 240 | assert((Op('a')>=Op('a')) and not(Op('a')>=Op('b')) and (Op('b')>=Op('a'))) |
| 234 | assert(('a' >= Op('a')) and not(Op('a') >= 'b') and (Op('b') >= Op('a'))) | 241 | assert(('a' >= Op('a')) and not(Op('a') >= 'b') and (Op('b') >= Op('a'))) |
| 242 | assert(Op(1) == Op(1) and Op(1) ~= Op(2)) | ||
| 243 | assert(Op('a') == Op('a') and Op('a') ~= Op('b')) | ||
| 244 | assert(a == a and a ~= b) | ||
| 245 | assert(Op(3) == c) | ||
| 235 | end | 246 | end |
| 236 | 247 | ||
| 237 | test() | 248 | test(Op(1), Op(2), Op(3)) |
| 238 | 249 | ||
| 239 | 250 | ||
| 240 | -- test `partial order' | 251 | -- test `partial order' |
