def to_latex_local
# FIXME: too dirty
if right.instance_of?(LiteralNode) ||
- right.instance_of?(RootNode)
+ right.instance_of?(RootNode) ||
+ right.instance_of?(FactorialNode)
+
unless right.to_s.match(/\A[-\.\d]+\z/)
return "#{left.to_latex}#{right.to_latex}"
end
end
describe MultipleNode do
- subject { MultipleNode.new(1, 2) }
- it 'operator is :*' do
- subject.operator.should == :*
+ context 'general' do
+ subject { MultipleNode.new(1, 2) }
+ it 'operator is :*' do
+ subject.operator.should == :*
+ end
+ end
+ [
+ LiteralNode.new('x'),
+ RootNode.new('2'),
+ FactorialNode.new(LiteralNode.new('x'), LiteralNode.new('2')),
+ ].each do |right|
+ context "with #{right.to_s}" do
+ subject { MultipleNode.new(LiteralNode.new(2), right) }
+ it { subject.to_latex.should match(/\A2#{Regexp.escape(right.to_latex)}\z/) }
+ end
end
end