spec/seq_spec.rb in raabro-1.0.5 vs spec/seq_spec.rb in raabro-1.1.0
- old
+ new
@@ -224,10 +224,25 @@
[ nil, 1, 6, 2, nil, :str, 'to' ]
] ]
)
expect(i.offset).to eq(8)
end
+
+ it 'stops when there is no progress' do
+
+ i = Raabro::Input.new('abc')
+
+ t = Raabro.seq(nil, i, :to_star, '*');
+
+ expect(t.to_a(:leaves => true)).to eq(
+ [ nil, 1, 0, 0, nil, :seq, [
+ [ nil, 1, 0, 0, nil, :rep, [
+ [ nil, 0, 0, 0, nil, :str, [] ]
+ ] ]
+ ] ]
+ )
+ end
end
describe 'the plus quantifier' do
it 'lets elements recur in sequences (hit)' do
@@ -260,33 +275,24 @@
[ nil, 0, 2, 0, nil, :str, [] ]
] ]
)
expect(i.offset).to eq(0)
end
+
+ it 'stops when there is no progress' do
+
+ i = Raabro::Input.new('abc')
+
+ t = Raabro.seq(nil, i, :to_star, '+');
+
+ expect(t.to_a(:leaves => true)).to eq(
+ [ nil, 1, 0, 0, nil, :seq, [
+ [ nil, 1, 0, 0, nil, :rep, [
+ [ nil, 0, 0, 0, nil, :str, [] ]
+ ] ]
+ ] ]
+ )
+ end
end
end
end
-
-#describe "fabr_seq()"
-#
-# context "quantifiers"
-# {
-# describe "fabr_qmark"
-# {
-# it "prunes when input->flags & FABR_F_PRUNE"
-# {
-# i.string = "tatota";
-# i.flags = FABR_F_PRUNE;
-#
-# t = fabr_seq("z", &i, _ta, _to, fabr_qmark, _ta, NULL);
-#
-# expect(fabr_tree_to_string(t, i.string, 0) ===f ""
-# "[ \"z\", 1, 0, 6, null, \"seq\", 0, [\n"
-# " [ null, 1, 0, 2, null, \"str\", 2, \"ta\" ],\n"
-# " [ null, 1, 2, 2, null, \"str\", 2, \"to\" ],\n"
-# " [ null, 1, 4, 2, null, \"str\", 2, \"ta\" ]\n"
-# "] ]");
-# }
-# }
-# }
-#}