20 local t3 = {}; |
20 local t3 = {}; |
21 u_table.move(t1, 1, 3, 1, t3); |
21 u_table.move(t1, 1, 3, 1, t3); |
22 u_table.move(t2, 1, 3, 3, t3); |
22 u_table.move(t2, 1, 3, 3, t3); |
23 assert.same({ "apple", "banana", "cat", "donkey", "elephant" }, t3); |
23 assert.same({ "apple", "banana", "cat", "donkey", "elephant" }, t3); |
24 end); |
24 end); |
|
25 it("supports overlapping regions", function () |
|
26 do |
|
27 local t1 = { "apple", "banana", "carrot", "date", "endive", "fig", "grapefruit" }; |
|
28 u_table.move(t1, 1, 3, 3); |
|
29 assert.same({ "apple", "banana", "apple", "banana", "carrot", "fig", "grapefruit" }, t1); |
|
30 end |
|
31 |
|
32 do |
|
33 local t1 = { "apple", "banana", "carrot", "date", "endive", "fig", "grapefruit" }; |
|
34 u_table.move(t1, 1, 3, 2); |
|
35 assert.same({ "apple", "apple", "banana", "carrot", "endive", "fig", "grapefruit" }, t1); |
|
36 end |
|
37 |
|
38 do |
|
39 local t1 = { "apple", "banana", "carrot", "date", "endive", "fig", "grapefruit" }; |
|
40 u_table.move(t1, 3, 5, 2); |
|
41 assert.same({ "apple", "carrot", "date", "endive", "endive", "fig", "grapefruit" }, t1); |
|
42 end |
|
43 |
|
44 do |
|
45 local t1 = { "apple", "banana", "carrot", "date", "endive", "fig", "grapefruit" }; |
|
46 u_table.move(t1, 3, 5, 6); |
|
47 assert.same({ "apple", "banana", "carrot", "date", "endive", "carrot", "date", "endive" }, t1); |
|
48 end |
|
49 |
|
50 do |
|
51 local t1 = { "apple", "banana", "carrot", "date", "endive", "fig", "grapefruit" }; |
|
52 u_table.move(t1, 3, 1, 3); |
|
53 assert.same({ "apple", "banana", "carrot", "date", "endive", "fig", "grapefruit" }, t1); |
|
54 end |
|
55 end); |
25 end); |
56 end); |
26 end); |
57 end); |
27 |
58 |
28 |
59 |