spec/alt_spec.rb in raabro-1.0.5 vs spec/alt_spec.rb in raabro-1.1.0
- old
+ new
@@ -134,8 +134,36 @@
[ :twox, 1, 0, 2, nil, :str, 'xx' ]
] ]
)
expect(i.offset).to eq(2)
end
+
+ it 'declares a single winner' do
+
+ i = Raabro::Input.new('xx', :prune => true)
+
+ t = Raabro.altg(nil, i, :twox, :onex)
+
+ expect(t.to_a(:leaves => true)).to eq(
+ [ nil, 1, 0, 2, nil, :altg, [
+ [ :twox, 1, 0, 2, nil, :str, 'xx' ]
+ ] ]
+ )
+ expect(i.offset).to eq(2)
+ end
+
+ it 'takes the longest and latest winner' do
+
+ i = Raabro::Input.new('xx', :prune => true)
+
+ t = Raabro.altg(nil, i, :twox, :onex, :deux)
+
+ expect(t.to_a(:leaves => true)).to eq(
+ [ nil, 1, 0, 2, nil, :altg, [
+ [ :deux, 1, 0, 2, nil, :str, 'xx' ]
+ ] ]
+ )
+ expect(i.offset).to eq(2)
+ end
end
end