# a: 27 mars 2001
# b: 16 septembre 2001

def bar; puts "\##{'-'*72}\#"; end

load "tests/test.conf"
require "UndoQueue.rb"

bar

a = UndoableArray[]; p a
a[3,4] = [42,43,1]; p a
a[0,1] = [1,2,3]; p a
a[2] = nil; p a
a.compact!; p a
a.undo; p a
a.undo; p a
a.undo; p a
a.undo; p a
a.redo; p a
a.redo; p a
a.redo; p a
a.redo; p a

bar

a = UndoableString.new; p a
a[0,0] = "patate poil"; p a
a[3,1] = nil; p a
a.gsub!(/t/,'s'); p a
a[6..-1] = "montagne"; p a
a.undo; p a
a.undo; p a
a.undo; p a
a.undo; p a

bar

a = UndoableHash.new; p a
a.replace({"oiseau" => "bird", "pelle" => "shovel"}); p a
a.modify {a.keys.each {|k| a["*#{k}*"]= :heh }}; p a
a.delete_if {|k,v| /oiseau/ =~ k }; p a
a[:blah]=:bof; p a
a.undo; p a
a.undo; p a
a.undo; p a
a.undo; p a

bar

a = UndoableArray.new
b = UndoableArray.new
b.undo_queue = a.undo_queue # share a same queue
z = 'puts "a=#{a.inspect} b=#{b.inspect}"'
eval z
a.push(1,2,3); eval z
b.push(1,2,3); eval z
a.push(:x,:y); eval z
a.undo    ; eval z
a.undo    ; eval z
a.undo    ; eval z

bar
