Skip to content

Commit

Permalink
fix tp_none nested in tp_drop bug
Browse files Browse the repository at this point in the history
  • Loading branch information
UlyssesZh committed Sep 8, 2024
1 parent ffbd288 commit 2276faa
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
1 change: 1 addition & 0 deletions lib/sscharter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,7 @@ def at name, preserve_beat: false, update_mark: false, &block
def tip_point mode, *args, preserve_beat: true, **opts, &block
@tip_point_mode_stack.push mode
if mode == :none
@tip_point_start_to_add_stack.push nil
@current_tip_point_stack.push nil
else
@tip_point_start_to_add_stack.push TipPointStart.new *args, **opts
Expand Down
38 changes: 31 additions & 7 deletions test/test_sscharter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -449,25 +449,49 @@ def test_nested_tip_points
assert_operator tp1, :!=, tp3
assert_operator tp3, :!=, tp5
assert_operator tp1, :!=, tp5
end

def test_tip_point_none
chart = Charter.open __method__
chart.offset offset = rand
chart.bpm bpm = rand * 300

group1 = nil
chain4 = chart.tip_point_chain 0, 0, 0 do
group = nil
chain = chart.tip_point_chain 0, 0, 0 do
t rand(100), rand(100)
b 1
group1 = tip_point_none do
group = tip_point_none do
t rand(100), rand(100)
b 1
end
t rand(100), rand(100)
b 1
end
assert_equal chain4.length, 4
assert_equal group1.length, 1
assert_equal chain4.map(&:type), %i[tap placeholder tap tap]
tp1, tp2, tp3, tp4 = chain4.map { _1[:tip_point] }
assert_equal chain.length, 4
assert_equal group.length, 1
assert_equal chain.map(&:type), %i[tap placeholder tap tap]
tp1, tp2, tp3, tp4 = chain.map { _1[:tip_point] }
assert_equal tp1, tp2
assert_equal tp2, tp4
assert_nil tp3

drop = chart.tip_point_drop 0, 0, 1 do
t rand(100), rand(100)
b 1
group = tip_point_none do
t rand(100), rand(100)
b 1
end
t rand(100), rand(100)
b 1
end
assert_equal drop.length, 5
assert_equal group.length, 1
assert_equal drop.map(&:type), %i[tap placeholder tap tap placeholder]
tp1, tp2, tp3, tp4, tp5 = drop.map { _1[:tip_point] }
assert_equal tp1, tp2
assert_equal tp4, tp5
assert_nil tp3
end

def test_bg_note
Expand Down

0 comments on commit 2276faa

Please sign in to comment.