Skip to content

Commit

Permalink
finished ported parser test to rspect
Browse files Browse the repository at this point in the history
  • Loading branch information
adamjmurray committed Jul 28, 2009
1 parent 1fd8178 commit 665b0d2
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 98 deletions.
53 changes: 50 additions & 3 deletions spec/parser_spec.rb
Expand Up @@ -176,7 +176,7 @@ def parsed_value(input)
durations += ['thirtysecond','thirty-second','sixtyfourth','sixty-fourth']
for base_duration in durations do
for multiplier in -2..2 do
for modifier in [nil, 't', '.', '.t', 't.', '..', '...'] do
for modifier in [nil, 't', '.', '.t', 't.', '..', '...', 't.t.t'] do
duration = Duration.new(multiplier, base_duration, modifier)
@parser.parse("#{multiplier}#{base_duration}#{modifier}").value.should == duration
if multiplier == 1 then
Expand All @@ -187,7 +187,7 @@ def parsed_value(input)
end
end
end
end
end

it 'should parse numerical durations' do
for duration in [0, 50, 100, 5000, -25] do
Expand Down Expand Up @@ -347,14 +347,61 @@ def parsed_value(input)


describe 'Chains' do
it 'should parse bare chains' do
it 'should parse simple chains' do
tree = @parser.parse '0:1:2:3'
tree.class.should == ChainNode
tree.children.length.should == 4
tree.children.each_with_index do |item,index|
item.value.should == index
end
end

it 'should parse heterogenous chains' do
@parser.parse '4:5:C4'
@parser.parse 'C4:mf:q.'
@parser.parse '[C4 E4]:fff'
@parser.parse '(4 5):(6 7)'
end
end

describe 'Other Constructs' do

it 'should parse choices' do
@parser.parse '4|5 | C4'
@parser.parse 'C4|mf|q.'
@parser.parse '[C4 E4]|fff'
@parser.parse '(4 5)|(6 7)'
end

it 'should parse simple foreach loops' do
@parser.parse '(1 2)@(3 4)'
@parser.parse '(1 $ 2)@(3 4)'
end

it 'should parse chained foreach loops' do
@parser.parse '(1 2)@(3 4)@(5 6)'
end

it 'should parse nested foreach loops' do
@parser.parse '((1 2)@(3 4))@(5 6)'
@parser.parse '((1 $ 2 $$)@(3 4 $))@(5 6)'
end

it 'should parse variable assignments and usages' do
@parser.parse '$X=1 2 3 4; $X'
@parser.parse '$X=1 2 3 4; $Y=5; $X $Y'
end

it 'should parse labels' do # DEPRECATED
@parser.parse '#label:5'
@parser.parse '#1:c:mf'
@parser.parse '#env:[1 250 1 500 0 250]'
end

it 'should parse parallel sequences' do
@parser.parse 'a == b'
@parser.parse 'a b c == c d e'
end
end


Expand Down
95 changes: 0 additions & 95 deletions test/test_parser.rb

This file was deleted.

0 comments on commit 665b0d2

Please sign in to comment.