NAME=t/manyundo
FILE=malloc://1024
CMDS=<<EOF
sH*
# Force a wraparound in the undo/redo buffer.
100sd +1
sH* ; ?v $$ ; ?e
sHj~{62}
sHj~{63}

# Make sure get back to the last available undo.
100sHu
sH* ; ?v $$ ; ?e

# And redo must work of course.
100sHr
sH* ; ?v $$ ; ?e

# Seeking inside the undo list must destroy the redo list.
50sHu
sH* ; ?v $$ ; ?e
sHj~{12}
sHj~{13}
sHj~{14}
s 0x100
sH* ; ?v $$ ; ?e
EOF
EXPECT=<<EOF
# Current seek @ 0x0
f undo_62 @ 0x25
f undo_61 @ 0x26
f undo_60 @ 0x27
f undo_59 @ 0x28
f undo_58 @ 0x29
f undo_57 @ 0x2a
f undo_56 @ 0x2b
f undo_55 @ 0x2c
f undo_54 @ 0x2d
f undo_53 @ 0x2e
f undo_52 @ 0x2f
f undo_51 @ 0x30
f undo_50 @ 0x31
f undo_49 @ 0x32
f undo_48 @ 0x33
f undo_47 @ 0x34
f undo_46 @ 0x35
f undo_45 @ 0x36
f undo_44 @ 0x37
f undo_43 @ 0x38
f undo_42 @ 0x39
f undo_41 @ 0x3a
f undo_40 @ 0x3b
f undo_39 @ 0x3c
f undo_38 @ 0x3d
f undo_37 @ 0x3e
f undo_36 @ 0x3f
f undo_35 @ 0x40
f undo_34 @ 0x41
f undo_33 @ 0x42
f undo_32 @ 0x43
f undo_31 @ 0x44
f undo_30 @ 0x45
f undo_29 @ 0x46
f undo_28 @ 0x47
f undo_27 @ 0x48
f undo_26 @ 0x49
f undo_25 @ 0x4a
f undo_24 @ 0x4b
f undo_23 @ 0x4c
f undo_22 @ 0x4d
f undo_21 @ 0x4e
f undo_20 @ 0x4f
f undo_19 @ 0x50
f undo_18 @ 0x51
f undo_17 @ 0x52
f undo_16 @ 0x53
f undo_15 @ 0x54
f undo_14 @ 0x55
f undo_13 @ 0x56
f undo_12 @ 0x57
f undo_11 @ 0x58
f undo_10 @ 0x59
f undo_9 @ 0x5a
f undo_8 @ 0x5b
f undo_7 @ 0x5c
f undo_6 @ 0x5d
f undo_5 @ 0x5e
f undo_4 @ 0x5f
f undo_3 @ 0x60
f undo_2 @ 0x61
f undo_1 @ 0x62
f undo_0 @ 0x63
# Current seek @ 0x64
0x64

{"offset":99,"cursor":0,"current":false}
{"offset":100,"cursor":0,"current":true}
# Current seek @ 0x25
f redo_0 @ 0x26
f redo_1 @ 0x27
f redo_2 @ 0x28
f redo_3 @ 0x29
f redo_4 @ 0x2a
f redo_5 @ 0x2b
f redo_6 @ 0x2c
f redo_7 @ 0x2d
f redo_8 @ 0x2e
f redo_9 @ 0x2f
f redo_10 @ 0x30
f redo_11 @ 0x31
f redo_12 @ 0x32
f redo_13 @ 0x33
f redo_14 @ 0x34
f redo_15 @ 0x35
f redo_16 @ 0x36
f redo_17 @ 0x37
f redo_18 @ 0x38
f redo_19 @ 0x39
f redo_20 @ 0x3a
f redo_21 @ 0x3b
f redo_22 @ 0x3c
f redo_23 @ 0x3d
f redo_24 @ 0x3e
f redo_25 @ 0x3f
f redo_26 @ 0x40
f redo_27 @ 0x41
f redo_28 @ 0x42
f redo_29 @ 0x43
f redo_30 @ 0x44
f redo_31 @ 0x45
f redo_32 @ 0x46
f redo_33 @ 0x47
f redo_34 @ 0x48
f redo_35 @ 0x49
f redo_36 @ 0x4a
f redo_37 @ 0x4b
f redo_38 @ 0x4c
f redo_39 @ 0x4d
f redo_40 @ 0x4e
f redo_41 @ 0x4f
f redo_42 @ 0x50
f redo_43 @ 0x51
f redo_44 @ 0x52
f redo_45 @ 0x53
f redo_46 @ 0x54
f redo_47 @ 0x55
f redo_48 @ 0x56
f redo_49 @ 0x57
f redo_50 @ 0x58
f redo_51 @ 0x59
f redo_52 @ 0x5a
f redo_53 @ 0x5b
f redo_54 @ 0x5c
f redo_55 @ 0x5d
f redo_56 @ 0x5e
f redo_57 @ 0x5f
f redo_58 @ 0x60
f redo_59 @ 0x61
f redo_60 @ 0x62
f redo_61 @ 0x63
f redo_62 @ 0x64
0x25

f undo_62 @ 0x25
f undo_61 @ 0x26
f undo_60 @ 0x27
f undo_59 @ 0x28
f undo_58 @ 0x29
f undo_57 @ 0x2a
f undo_56 @ 0x2b
f undo_55 @ 0x2c
f undo_54 @ 0x2d
f undo_53 @ 0x2e
f undo_52 @ 0x2f
f undo_51 @ 0x30
f undo_50 @ 0x31
f undo_49 @ 0x32
f undo_48 @ 0x33
f undo_47 @ 0x34
f undo_46 @ 0x35
f undo_45 @ 0x36
f undo_44 @ 0x37
f undo_43 @ 0x38
f undo_42 @ 0x39
f undo_41 @ 0x3a
f undo_40 @ 0x3b
f undo_39 @ 0x3c
f undo_38 @ 0x3d
f undo_37 @ 0x3e
f undo_36 @ 0x3f
f undo_35 @ 0x40
f undo_34 @ 0x41
f undo_33 @ 0x42
f undo_32 @ 0x43
f undo_31 @ 0x44
f undo_30 @ 0x45
f undo_29 @ 0x46
f undo_28 @ 0x47
f undo_27 @ 0x48
f undo_26 @ 0x49
f undo_25 @ 0x4a
f undo_24 @ 0x4b
f undo_23 @ 0x4c
f undo_22 @ 0x4d
f undo_21 @ 0x4e
f undo_20 @ 0x4f
f undo_19 @ 0x50
f undo_18 @ 0x51
f undo_17 @ 0x52
f undo_16 @ 0x53
f undo_15 @ 0x54
f undo_14 @ 0x55
f undo_13 @ 0x56
f undo_12 @ 0x57
f undo_11 @ 0x58
f undo_10 @ 0x59
f undo_9 @ 0x5a
f undo_8 @ 0x5b
f undo_7 @ 0x5c
f undo_6 @ 0x5d
f undo_5 @ 0x5e
f undo_4 @ 0x5f
f undo_3 @ 0x60
f undo_2 @ 0x61
f undo_1 @ 0x62
f undo_0 @ 0x63
# Current seek @ 0x64
0x64

f undo_12 @ 0x25
f undo_11 @ 0x26
f undo_10 @ 0x27
f undo_9 @ 0x28
f undo_8 @ 0x29
f undo_7 @ 0x2a
f undo_6 @ 0x2b
f undo_5 @ 0x2c
f undo_4 @ 0x2d
f undo_3 @ 0x2e
f undo_2 @ 0x2f
f undo_1 @ 0x30
f undo_0 @ 0x31
# Current seek @ 0x32
f redo_0 @ 0x33
f redo_1 @ 0x34
f redo_2 @ 0x35
f redo_3 @ 0x36
f redo_4 @ 0x37
f redo_5 @ 0x38
f redo_6 @ 0x39
f redo_7 @ 0x3a
f redo_8 @ 0x3b
f redo_9 @ 0x3c
f redo_10 @ 0x3d
f redo_11 @ 0x3e
f redo_12 @ 0x3f
f redo_13 @ 0x40
f redo_14 @ 0x41
f redo_15 @ 0x42
f redo_16 @ 0x43
f redo_17 @ 0x44
f redo_18 @ 0x45
f redo_19 @ 0x46
f redo_20 @ 0x47
f redo_21 @ 0x48
f redo_22 @ 0x49
f redo_23 @ 0x4a
f redo_24 @ 0x4b
f redo_25 @ 0x4c
f redo_26 @ 0x4d
f redo_27 @ 0x4e
f redo_28 @ 0x4f
f redo_29 @ 0x50
f redo_30 @ 0x51
f redo_31 @ 0x52
f redo_32 @ 0x53
f redo_33 @ 0x54
f redo_34 @ 0x55
f redo_35 @ 0x56
f redo_36 @ 0x57
f redo_37 @ 0x58
f redo_38 @ 0x59
f redo_39 @ 0x5a
f redo_40 @ 0x5b
f redo_41 @ 0x5c
f redo_42 @ 0x5d
f redo_43 @ 0x5e
f redo_44 @ 0x5f
f redo_45 @ 0x60
f redo_46 @ 0x61
f redo_47 @ 0x62
f redo_48 @ 0x63
f redo_49 @ 0x64
0x32

{"offset":49,"cursor":0,"current":false}
{"offset":50,"cursor":0,"current":true}
{"offset":51,"cursor":0,"current":false}
f undo_13 @ 0x25
f undo_12 @ 0x26
f undo_11 @ 0x27
f undo_10 @ 0x28
f undo_9 @ 0x29
f undo_8 @ 0x2a
f undo_7 @ 0x2b
f undo_6 @ 0x2c
f undo_5 @ 0x2d
f undo_4 @ 0x2e
f undo_3 @ 0x2f
f undo_2 @ 0x30
f undo_1 @ 0x31
f undo_0 @ 0x32
# Current seek @ 0x100
0x100

EOF
RUN
