Files
wren/test/core/object/same.wren
Bob Nystrom 58e4d26648 "IO" -> "System".
Get rid of the separate opt-in IO class and replace it with a core
System class.

- Remove wren_io.c, wren_io.h, and io.wren.
- Remove the flags that disable it.
- Remove the overloads for print() with different arity. (It was an
  experiment, but I don't think it's that useful.)
- Remove IO.read(). That will reappear using libuv in the CLI at some
  point.
- Remove IO.time. Doesn't seem to have been used.
- Update all of the tests, docs, etc.

I'm sorry for all the breakage this causes, but I think "System" is a
better name for this class (it makes it natural to add things like
"System.gc()") and frees up "IO" for referring to the CLI's IO module.
2015-09-15 07:46:09 -07:00

44 lines
1.3 KiB
Plaintext

// Value types compare by value.
System.print(Object.same(true, true)) // expect: true
System.print(Object.same(true, false)) // expect: false
System.print(Object.same(null, null)) // expect: true
System.print(Object.same(1 + 2, 2 + 1)) // expect: true
System.print(Object.same(1 + 2, 2 + 2)) // expect: false
System.print(Object.same(1..2, 1..2)) // expect: true
System.print(Object.same(1..2, 1..3)) // expect: false
System.print(Object.same("ab", "a" + "b")) // expect: true
System.print(Object.same("ab", "a" + "c")) // expect: false
// Different types are never the same.
System.print(Object.same(null, false)) // expect: false
System.print(Object.same(true, 2)) // expect: false
System.print(Object.same(1..2, 2)) // expect: false
System.print(Object.same("1", 1)) // expect: false
// Classes compare by identity.
System.print(Object.same(Bool, Num)) // expect: false
System.print(Object.same(Bool, Bool)) // expect: true
// Other types compare by identity.
class Foo {
construct new() {}
}
var foo = Foo.new()
System.print(Object.same(foo, foo)) // expect: true
System.print(Object.same(foo, Foo.new())) // expect: false
// Ignores == operators.
class Bar {
construct new() {}
==(other) { true }
}
var bar = Bar.new()
System.print(Object.same(bar, bar)) // expect: true
System.print(Object.same(bar, Bar.new())) // expect: false