1
0
forked from Mirror/wren
Files
wren/test/core/list/insert.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

42 lines
790 B
Plaintext

// Add to empty list.
var a = []
a.insert(0, 1)
System.print(a) // expect: [1]
// Normal indices.
var b = [1, 2, 3]
b.insert(0, 4)
System.print(b) // expect: [4, 1, 2, 3]
var c = [1, 2, 3]
c.insert(1, 4)
System.print(c) // expect: [1, 4, 2, 3]
var d = [1, 2, 3]
d.insert(2, 4)
System.print(d) // expect: [1, 2, 4, 3]
var e = [1, 2, 3]
e.insert(3, 4)
System.print(e) // expect: [1, 2, 3, 4]
// Negative indices.
var f = [1, 2, 3]
f.insert(-4, 4)
System.print(f) // expect: [4, 1, 2, 3]
var g = [1, 2, 3]
g.insert(-3, 4)
System.print(g) // expect: [1, 4, 2, 3]
var h = [1, 2, 3]
h.insert(-2, 4)
System.print(h) // expect: [1, 2, 4, 3]
var i = [1, 2, 3]
i.insert(-1, 4)
System.print(i) // expect: [1, 2, 3, 4]
// Returns.inserted value.
System.print([1, 2].insert(0, 3)) // expect: 3