Files
wren/test/core/function/equality.wren
Bob Nystrom 5fb6186d7d Make constructors just methods.
* Eliminate "new" reserved word.
* Allow "this" before a method definition to define a constructor.
* Only create a default constructor for classes that don't define one.
2015-07-10 09:18:22 -07:00

17 lines
618 B
Plaintext

// Not structurally equal.
IO.print(Fn.new { 123 } == Fn.new { 123 }) // expect: false
IO.print(Fn.new { 123 } != Fn.new { 123 }) // expect: true
// Not equal to other types.
IO.print(Fn.new { 123 } == 1) // expect: false
IO.print(Fn.new { 123 } == false) // expect: false
IO.print(Fn.new { 123 } == "fn 123") // expect: false
IO.print(Fn.new { 123 } != 1) // expect: true
IO.print(Fn.new { 123 } != false) // expect: true
IO.print(Fn.new { 123 } != "fn 123") // expect: true
// Equal by identity.
var f = Fn.new { 123 }
IO.print(f == f) // expect: true
IO.print(f != f) // expect: false