robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

Justin M. KeyesMerge #40865 from justinmk/fixcif907614088

master
19.9 KiB673 linesraw
1local t = require('test.unit.testutil')
2local describe, before_each = t.describe, t.before_each
3local itp = t.gen_itp(t.it)
4
5local ffi = t.ffi
6local eq = t.eq
7local ok = t.ok
8
9local lib = t.cimport('./src/nvim/marktree.h')
10
11local function tablelength(tbl)
12  local count = 0
13  for _ in pairs(tbl) do
14    count = count + 1
15  end
16  return count
17end
18
19local function pos_leq(a, b)
20  return a[1] < b[1] or (a[1] == b[1] and a[2] <= b[2])
21end
22
23-- Checks that shadow and tree is consistent, and optionally
24-- return the order
25local function shadoworder(tree, shadow, iter, giveorder)
26  ok(iter ~= nil)
27  local status = lib.marktree_itr_first(tree, iter)
28  local count = 0
29  local pos2id, id2pos = {}, {}
30  local last
31  if not status and next(shadow) == nil then
32    return pos2id, id2pos
33  end
34  repeat
35    local mark = lib.marktree_itr_current(iter)
36    local id = tonumber(mark.id)
37    local spos = shadow[id]
38    eq(mark.pos.row, spos[1], mark.id)
39    eq(mark.pos.col, spos[2], mark.id)
40    if lib.mt_right_test(mark) ~= spos[3] then
41      error('invalid gravity for ' .. id .. ':(' .. mark.pos.row .. ', ' .. mark.pos.col .. ')')
42    end
43    if count > 0 then
44      if not pos_leq(last, spos) then
45        error('DISORDER')
46      end
47    end
48    count = count + 1
49    last = spos
50    if giveorder then
51      pos2id[count] = id
52      id2pos[id] = count
53    end
54  until not lib.marktree_itr_next(tree, iter)
55  local shadowlen = tablelength(shadow)
56  if shadowlen ~= count then
57    error('missed some keys? (shadow ' .. shadowlen .. ', tree ' .. count .. ')')
58  end
59  return id2pos, pos2id
60end
61
62local function shadowsplice(shadow, start, old_extent, new_extent)
63  local old_end = {
64    start[1] + old_extent[1],
65    (old_extent[1] == 0 and start[2] or 0) + old_extent[2],
66  }
67  local new_end = {
68    start[1] + new_extent[1],
69    (new_extent[1] == 0 and start[2] or 0) + new_extent[2],
70  }
71  local delta = { new_end[1] - old_end[1], new_end[2] - old_end[2] }
72  for _, pos in pairs(shadow) do
73    if pos_leq(start, pos) then
74      if pos_leq(pos, old_end) then
75        -- delete region
76        if pos[3] then -- right gravity
77          pos[1], pos[2] = new_end[1], new_end[2]
78        else
79          pos[1], pos[2] = start[1], start[2]
80        end
81      else
82        if pos[1] == old_end[1] then
83          pos[2] = pos[2] + delta[2]
84        end
85        pos[1] = pos[1] + delta[1]
86      end
87    end
88  end
89end
90
91local function dosplice(tree, shadow, start, old, new)
92  lib.marktree_splice(tree, start[1], start[2], old[1], old[2], new[1], new[2])
93  shadowsplice(shadow, start, old, new)
94end
95
96local ns = 10
97local last_id = nil
98
99local function put(tree, row, col, gravity, end_row, end_col, end_gravity)
100  last_id = last_id + 1
101  local my_id = last_id
102
103  end_row = end_row or -1
104  end_col = end_col or -1
105  end_gravity = end_gravity or false
106
107  lib.marktree_put_test(tree, ns, my_id, row, col, gravity, end_row, end_col, end_gravity, false)
108  return my_id
109end
110
111local function put_meta(tree, row, col, gravitate, meta)
112  last_id = last_id + 1
113  local my_id = last_id
114
115  lib.marktree_put_test(tree, ns, my_id, row, col, gravitate, -1, -1, false, meta)
116  return my_id
117end
118
119describe('marktree', function()
120  before_each(function()
121    last_id = 0
122  end)
123
124  itp('works', function()
125    local tree = ffi.new('MarkTree[1]') -- zero initialized by luajit
126    local shadow = {}
127    local iter = ffi.new('MarkTreeIter[1]')
128    local iter2 = ffi.new('MarkTreeIter[1]')
129
130    for i = 1, 100 do
131      for j = 1, 100 do
132        local gravitate = (i % 2) > 0
133        local id = put(tree, j, i, gravitate)
134        ok(id > 0)
135        eq(nil, shadow[id])
136        shadow[id] = { j, i, gravitate }
137      end
138      -- checking every insert is too slow, but this is ok
139      lib.marktree_check(tree)
140    end
141
142    -- ss = lib.mt_inspect_rec(tree)
143    -- io.stdout:write(ffi.string(ss))
144    -- io.stdout:flush()
145
146    local id2pos, pos2id = shadoworder(tree, shadow, iter)
147    eq({}, pos2id) -- not set if not requested
148    eq({}, id2pos)
149
150    for i, ipos in pairs(shadow) do
151      local p = lib.marktree_lookup_ns(tree, ns, i, false, iter)
152      eq(ipos[1], p.pos.row)
153      eq(ipos[2], p.pos.col)
154      local k = lib.marktree_itr_current(iter)
155      eq(ipos[1], k.pos.row)
156      eq(ipos[2], k.pos.col, ipos[1])
157      lib.marktree_itr_next(tree, iter)
158      -- TODO(bfredl): use id2pos to check neighbour?
159      -- local k2 = lib.marktree_itr_current(iter)
160    end
161
162    for i, ipos in pairs(shadow) do
163      lib.marktree_itr_get(tree, ipos[1], ipos[2], iter)
164      local k = lib.marktree_itr_current(iter)
165      eq(i, tonumber(k.id))
166      eq(ipos[1], k.pos.row)
167      eq(ipos[2], k.pos.col)
168    end
169
170    ok(lib.marktree_itr_first(tree, iter))
171    local del = lib.marktree_itr_current(iter)
172
173    lib.marktree_del_itr(tree, iter, false)
174    shadow[tonumber(del.id)] = nil
175    shadoworder(tree, shadow, iter)
176
177    for _, ci in ipairs({ 0, -1, 1, -2, 2, -10, 10 }) do
178      for i = 1, 100 do
179        lib.marktree_itr_get(tree, i, 50 + ci, iter)
180        local k = lib.marktree_itr_current(iter)
181        local id = tonumber(k.id)
182        eq(shadow[id][1], k.pos.row)
183        eq(shadow[id][2], k.pos.col)
184        lib.marktree_del_itr(tree, iter, false)
185        shadow[id] = nil
186      end
187      lib.marktree_check(tree)
188      shadoworder(tree, shadow, iter)
189    end
190
191    -- NB: this is quite rudimentary. We rely on
192    -- functional tests exercising splicing quite a bit
193    lib.marktree_check(tree)
194    dosplice(tree, shadow, { 2, 2 }, { 0, 5 }, { 1, 2 })
195    lib.marktree_check(tree)
196    shadoworder(tree, shadow, iter)
197    dosplice(tree, shadow, { 30, 2 }, { 30, 5 }, { 1, 2 })
198    lib.marktree_check(tree)
199    shadoworder(tree, shadow, iter)
200
201    dosplice(tree, shadow, { 5, 3 }, { 0, 2 }, { 0, 5 })
202    shadoworder(tree, shadow, iter)
203    lib.marktree_check(tree)
204
205    -- build then burn (HOORAY! HOORAY!)
206    while next(shadow) do
207      lib.marktree_itr_first(tree, iter)
208      -- delete every other key for fun and profit
209      while true do
210        local k = lib.marktree_itr_current(iter)
211        lib.marktree_del_itr(tree, iter, false)
212        ok(shadow[tonumber(k.id)] ~= nil)
213        shadow[tonumber(k.id)] = nil
214        local stat = lib.marktree_itr_next(tree, iter)
215        if not stat then
216          break
217        end
218      end
219      lib.marktree_check(tree)
220      shadoworder(tree, shadow, iter2)
221    end
222
223    -- Check iterator validity for 2 specific edge cases:
224    -- https://github.com/neovim/neovim/pull/14719
225    lib.marktree_clear(tree)
226    for i = 1, 20 do
227      put(tree, i, i, false)
228    end
229
230    lib.marktree_itr_get(tree, 10, 10, iter)
231    lib.marktree_del_itr(tree, iter, false)
232    eq(11, iter[0].x.key[iter[0].i].pos.col)
233
234    lib.marktree_itr_get(tree, 11, 11, iter)
235    lib.marktree_del_itr(tree, iter, false)
236    eq(12, iter[0].x.key[iter[0].i].pos.col)
237  end)
238
239  itp("'intersect_mov' function works correctly", function()
240    local function mov(x, y, w)
241      local xa = ffi.new('uint64_t[?]', #x)
242      for i, xi in ipairs(x) do
243        xa[i - 1] = xi
244      end
245      local ya = ffi.new('uint64_t[?]', #y)
246      for i, yi in ipairs(y) do
247        ya[i - 1] = yi
248      end
249      local wa = ffi.new('uint64_t[?]', #w)
250      for i, wi in ipairs(w) do
251        wa[i - 1] = wi
252      end
253
254      local dummy_size = #x + #y + #w
255      local wouta = ffi.new('uint64_t[?]', dummy_size)
256      local douta = ffi.new('uint64_t[?]', dummy_size)
257      local wsize = ffi.new('size_t[1]')
258      wsize[0] = dummy_size
259      local dsize = ffi.new('size_t[1]')
260      dsize[0] = dummy_size
261
262      local status = lib.intersect_mov_test(xa, #x, ya, #y, wa, #w, wouta, wsize, douta, dsize)
263      if status == 0 then
264        error 'wowza'
265      end
266
267      local wout, dout = {}, {}
268      for i = 0, tonumber(wsize[0]) - 1 do
269        table.insert(wout, tonumber(wouta[i]))
270      end
271      for i = 0, tonumber(dsize[0]) - 1 do
272        table.insert(dout, tonumber(douta[i]))
273      end
274      return { wout, dout }
275    end
276
277    eq({ {}, {} }, mov({}, { 2, 3 }, { 2, 3 }))
278    eq({ { 2, 3 }, {} }, mov({}, {}, { 2, 3 }))
279    eq({ { 2, 3 }, {} }, mov({ 2, 3 }, {}, {}))
280    eq({ {}, { 2, 3 } }, mov({}, { 2, 3 }, {}))
281
282    eq({ { 1, 5 }, {} }, mov({ 1, 2, 5 }, { 2, 3 }, { 3 }))
283    eq({ { 1, 2 }, {} }, mov({ 1, 2, 5 }, { 5, 10 }, { 10 }))
284    eq({ { 1, 2 }, { 5 } }, mov({ 1, 2 }, { 5, 10 }, { 10 }))
285    eq({ { 1, 3, 5, 7, 9 }, { 2, 4, 6, 8, 10 } }, mov({ 1, 3, 5, 7, 9 }, { 2, 4, 6, 8, 10 }, {}))
286    eq({ { 1, 3, 5, 7, 9 }, { 2, 6, 10 } }, mov({ 1, 3, 5, 7, 9 }, { 2, 4, 6, 8, 10 }, { 4, 8 }))
287    eq({ { 1, 4, 7 }, { 2, 5, 8 } }, mov({ 1, 3, 4, 6, 7, 9 }, { 2, 3, 5, 6, 8, 9 }, {}))
288    eq({ { 1, 4, 7 }, {} }, mov({ 1, 3, 4, 6, 7, 9 }, { 2, 3, 5, 6, 8, 9 }, { 2, 5, 8 }))
289    eq(
290      { { 0, 1, 4, 7, 10 }, {} },
291      mov({ 1, 3, 4, 6, 7, 9 }, { 2, 3, 5, 6, 8, 9 }, { 0, 2, 5, 8, 10 })
292    )
293  end)
294
295  local function check_intersections(tree)
296    lib.marktree_check(tree)
297    -- to debug stuff disable this branch
298    if true == true then
299      ok(lib.marktree_check_intersections(tree))
300      return
301    end
302
303    local str1 = lib.mt_inspect(tree, true, true)
304    local dot1 = ffi.string(str1.data, str1.size)
305
306    local val = lib.marktree_check_intersections(tree)
307    if not val then
308      local str2 = lib.mt_inspect(tree, true, true)
309      local dot2 = ffi.string(str2.data, str2.size)
310      print('actual:\n\n' .. 'Xafile.dot' .. '\n\nexpected:\n\n' .. 'Xefile.dot' .. '\n')
311      print('nivå', tree[0].root.level)
312      io.stdout:flush()
313      local afil = io.open('Xafile.dot', 'wb')
314      afil:write(dot1)
315      afil:close()
316      local efil = io.open('Xefile.dot', 'wb')
317      efil:write(dot2)
318      efil:close()
319      ok(false)
320    else
321      ffi.C.xfree(str1.data)
322    end
323  end
324
325  itp('works with intersections', function()
326    local tree = ffi.new('MarkTree[1]') -- zero initialized by luajit
327
328    local ids = {}
329
330    for i = 1, 80 do
331      table.insert(ids, put(tree, 1, i, false, 2, 100 - i, false))
332      check_intersections(tree)
333    end
334    for i = 1, 80 do
335      lib.marktree_del_pair_test(tree, ns, ids[i])
336      check_intersections(tree)
337    end
338    ids = {}
339
340    for i = 1, 80 do
341      table.insert(ids, put(tree, 1, i, false, 2, 100 - i, false))
342      check_intersections(tree)
343    end
344
345    for i = 1, 10 do
346      for j = 1, 8 do
347        local ival = (j - 1) * 10 + i
348        lib.marktree_del_pair_test(tree, ns, ids[ival])
349        check_intersections(tree)
350      end
351    end
352  end)
353
354  itp('works with intersections with a big tree', function()
355    local tree = ffi.new('MarkTree[1]') -- zero initialized by luajit
356
357    local ids = {}
358
359    for i = 1, 1000 do
360      table.insert(ids, put(tree, 1, i, false, 2, 1000 - i, false))
361      if i % 10 == 1 then
362        check_intersections(tree)
363      end
364    end
365
366    check_intersections(tree)
367    eq(2000, tree[0].n_keys)
368    ok(tree[0].root.level >= 2)
369
370    local iter = ffi.new('MarkTreeIter[1]')
371
372    local k = 0
373    for i = 1, 20 do
374      for j = 1, 50 do
375        k = k + 1
376        local ival = (j - 1) * 20 + i
377        if false == true then -- if there actually is a failure, this branch will fail out at the actual spot of the error
378          lib.marktree_lookup_ns(tree, ns, ids[ival], false, iter)
379          lib.marktree_del_itr(tree, iter, false)
380          check_intersections(tree)
381
382          lib.marktree_lookup_ns(tree, ns, ids[ival], true, iter)
383          lib.marktree_del_itr(tree, iter, false)
384          check_intersections(tree)
385        else
386          lib.marktree_del_pair_test(tree, ns, ids[ival])
387          if k % 5 == 1 then
388            check_intersections(tree)
389          end
390        end
391      end
392    end
393
394    eq(0, tree[0].n_keys)
395  end)
396
397  itp('works with intersections and marktree_splice', function()
398    local tree = ffi.new('MarkTree[1]') -- zero initialized by luajit
399
400    for i = 1, 1000 do
401      put(tree, 1, i, false, 2, 1000 - i, false)
402      if i % 10 == 1 then
403        check_intersections(tree)
404      end
405    end
406
407    check_intersections(tree)
408    eq(2000, tree[0].n_keys)
409    ok(tree[0].root.level >= 2)
410
411    for _ = 1, 10 do
412      lib.marktree_splice(tree, 0, 0, 0, 100, 0, 0)
413      check_intersections(tree)
414    end
415  end)
416
417  itp('marktree_move should preserve key order', function()
418    local tree = ffi.new('MarkTree[1]') -- zero initialized by luajit
419    local iter = ffi.new('MarkTreeIter[1]')
420    local ids = {}
421
422    -- new index and old index look the same, but still have to move because
423    -- pos will get updated
424    table.insert(ids, put(tree, 1, 1, false, 1, 3, false))
425    table.insert(ids, put(tree, 1, 3, false, 1, 3, false))
426    table.insert(ids, put(tree, 1, 3, false, 1, 3, false))
427    table.insert(ids, put(tree, 1, 3, false, 1, 3, false))
428
429    lib.marktree_lookup_ns(tree, ns, ids[3], false, iter)
430    lib.marktree_move(tree, iter, 1, 2)
431
432    check_intersections(tree)
433  end)
434
435  itp('works with intersections and marktree_move', function()
436    local tree = ffi.new('MarkTree[1]') -- zero initialized by luajit
437
438    local ids = {}
439
440    for i = 1, 1000 do
441      table.insert(ids, put(tree, 1, i, false, 2, 1000 - i, false))
442      if i % 10 == 1 then
443        check_intersections(tree)
444      end
445    end
446
447    local iter = ffi.new('MarkTreeIter[1]')
448    for i = 1, 1000 do
449      local which = i % 2
450      lib.marktree_lookup_ns(tree, ns, ids[i], which, iter)
451      lib.marktree_move(tree, iter, 1 + which, 500 + i)
452      if i % 10 == 1 then
453        check_intersections(tree)
454      end
455    end
456  end)
457
458  itp('works with intersections with a even bigger tree', function()
459    local tree = ffi.new('MarkTree[1]') -- zero initialized by luajit
460
461    local ids = {}
462
463    -- too much overhead on ASAN
464    local size_factor = t.is_asan() and 3 or 10
465
466    local at_row = {}
467    for i = 1, 10 do
468      at_row[i] = {}
469    end
470
471    local size = 1000 * size_factor
472    local k = 1
473    while k <= size do
474      for row1 = 1, 9 do
475        for row2 = row1, 10 do -- note row2 can be == row1, leads to empty ranges being tested when k > size/2
476          if k > size then
477            break
478          end
479          local id = put(tree, row1, k, false, row2, size - k, false)
480          table.insert(ids, id)
481          for i = row1 + 1, row2 do
482            table.insert(at_row[i], id)
483          end
484          --if tree[0].root.level == 4 then error("kk"..k) end
485          if k % 100 * size_factor == 1 or (k < 2000 and k % 100 == 1) then
486            check_intersections(tree)
487          end
488          k = k + 1
489        end
490      end
491    end
492
493    eq(2 * size, tree[0].n_keys)
494    ok(tree[0].root.level >= 3)
495    check_intersections(tree)
496
497    local iter = ffi.new('MarkTreeIter[1]')
498    local pair = ffi.new('MTPair[1]')
499    for i = 1, 10 do
500      -- use array as set and not {[id]=true} map, to detect duplicates
501      local set = {}
502      eq(true, ffi.C.marktree_itr_get_overlap(tree, i, 0, iter))
503      while ffi.C.marktree_itr_step_overlap(tree, iter, pair) do
504        local id = tonumber(pair[0].start.id)
505        table.insert(set, id)
506      end
507      table.sort(set)
508      eq(at_row[i], set)
509    end
510
511    k = 0
512    for i = 1, 100 do
513      for j = 1, (10 * size_factor) do
514        k = k + 1
515        local ival = (j - 1) * 100 + i
516        lib.marktree_del_pair_test(tree, ns, ids[ival])
517        -- just a few stickprov, if there is trouble we need to check
518        -- everyone using the code in the "big tree" case above
519        if k % 100 * size_factor == 0 or (k > 3000 and k % 200 == 0) then
520          check_intersections(tree)
521        end
522      end
523    end
524
525    eq(0, tree[0].n_keys)
526  end)
527
528  itp('works with intersections with a even bigger tree and splice', function()
529    local tree = ffi.new('MarkTree[1]') -- zero initialized by luajit
530
531    -- too much overhead on ASAN
532    local size_factor = t.is_asan() and 3 or 10
533
534    local at_row = {}
535    for i = 1, 10 do
536      at_row[i] = {}
537    end
538
539    local size = 1000 * size_factor
540    local k = 1
541    while k <= size do
542      for row1 = 1, 9 do
543        for row2 = row1, 10 do -- note row2 can be == row1, leads to empty ranges being tested when k > size/2
544          if k > size then
545            break
546          end
547          local id = put(tree, row1, k, false, row2, size - k, false)
548          for i = row1 + 1, row2 do
549            table.insert(at_row[i], id)
550          end
551          --if tree[0].root.level == 4 then error("kk"..k) end
552          if k % 100 * size_factor == 1 or (k < 2000 and k % 100 == 1) then
553            check_intersections(tree)
554          end
555          k = k + 1
556        end
557      end
558    end
559
560    eq(2 * size, tree[0].n_keys)
561    ok(tree[0].root.level >= 3)
562    check_intersections(tree)
563
564    for _ = 1, 10 do
565      for j = 3, 8 do
566        lib.marktree_splice(tree, j, 0, 0, 200, 0, 0)
567        check_intersections(tree)
568      end
569    end
570  end)
571
572  itp('works with meta counts', function()
573    local tree = ffi.new('MarkTree[1]') -- zero initialized by luajit
574
575    -- add
576    local shadow = {}
577    for i = 1, 100 do
578      for j = 1, 100 do
579        local gravitate = (i % 2) > 0
580        local inline = (j == 3 or j == 50 or j == 51 or j == 55) and i % 11 == 1
581        inline = inline or ((j >= 80 and j < 85) and i % 3 == 1)
582        local id = put_meta(tree, j, i, gravitate, inline)
583        if inline then
584          shadow[id] = { j, i, gravitate }
585        end
586      end
587      -- checking every insert is too slow, but this is ok
588      lib.marktree_check(tree)
589    end
590
591    lib.marktree_check(tree)
592    local iter = ffi.new('MarkTreeIter[1]')
593    local filter = ffi.new('uint32_t[4]')
594    filter[0] = -1ULL
595    ok(lib.marktree_itr_get_filter(tree, 0, 0, 101, 0, filter, iter))
596    local seen = {}
597    repeat
598      local mark = lib.marktree_itr_current(iter)
599      eq(nil, seen[mark.id])
600      seen[mark.id] = true
601      eq(mark.pos.row, shadow[mark.id][1])
602      eq(mark.pos.col, shadow[mark.id][2])
603    until not lib.marktree_itr_next_filter(tree, iter, 101, 0, filter)
604    eq(tablelength(seen), tablelength(shadow))
605
606    -- test skipping subtrees to find the filtered mark at line 50
607    for i = 4, 50 do
608      ok(lib.marktree_itr_get_filter(tree, i, 0, 60, 0, filter, iter))
609      local mark = lib.marktree_itr_current(iter)
610      eq({ 50, 50, 1 }, { mark.id, mark.pos.row, mark.pos.col })
611    end
612
613    -- delete
614    for id = 1, 10000, 2 do
615      lib.marktree_lookup_ns(tree, ns, id, false, iter)
616      if shadow[id] then
617        local mark = lib.marktree_itr_current(iter)
618        eq(mark.pos.row, shadow[id][1])
619        eq(mark.pos.col, shadow[id][2])
620        shadow[id] = nil
621      end
622      lib.marktree_del_itr(tree, iter, false)
623      if id % 100 == 1 then
624        lib.marktree_check(tree)
625      end
626    end
627
628    -- Splice!
629    dosplice(tree, shadow, { 82, 0 }, { 0, 50 }, { 0, 0 })
630    lib.marktree_check(tree)
631
632    dosplice(tree, shadow, { 81, 50 }, { 2, 50 }, { 1, 0 })
633    lib.marktree_check(tree)
634
635    dosplice(tree, shadow, { 2, 50 }, { 1, 50 }, { 0, 10 })
636    lib.marktree_check(tree)
637
638    ok(lib.marktree_itr_get_filter(tree, 0, 0, 101, 0, filter, iter))
639    seen = {}
640    repeat
641      local mark = lib.marktree_itr_current(iter)
642      eq(nil, seen[mark.id])
643      seen[mark.id] = true
644      eq(mark.pos.row, shadow[mark.id][1])
645      eq(mark.pos.col, shadow[mark.id][2])
646    until not lib.marktree_itr_next_filter(tree, iter, 101, 0, filter)
647    eq(tablelength(seen), tablelength(shadow))
648  end)
649
650  itp('works with edge case splicing overlapping ranges #37867', function()
651    local tree = ffi.new('MarkTree[1]') -- zero initialized by luajit
652    put(tree, 190, 48, false)
653    put(tree, 48, 48, true)
654    put(tree, 190, 48, false)
655    put(tree, 166, 48, false, 166, 48, false)
656    put(tree, 48, 48, true, 48, 48, false)
657    put(tree, 48, 48, true, 48, 48, false)
658    put(tree, 48, 48, true, 255, 48, false)
659    put(tree, 131, 48, false, 48, 48, false)
660    put(tree, 131, 48, false, 48, 48, false)
661    put(tree, 48, 48, true, 131, 48, false)
662    put(tree, 48, 48, false, 216, 48, false)
663    put(tree, 172, 48, false, 51, 48, false)
664    put(tree, 131, 48, false, 131, 48, false)
665    put(tree, 156, 48, false, 131, 48, false)
666    put(tree, 135, 48, false, 166, 48, false)
667    put(tree, 172, 48, false, 250, 48, false)
668    put(tree, 48, 48, false, 143, 48, false)
669    ok(lib.marktree_check_intersections(tree))
670    lib.marktree_splice(tree, 48, 0, 139, 0, 0, 0)
671    ok(lib.marktree_check_intersections(tree))
672  end)
673end)