-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ruby wrapper for parser #60
base: master
Are you sure you want to change the base?
Changes from 4 commits
588fa76
cf77487
300c769
5980a4a
a2f88e2
c20e7a0
7e9ca53
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,5 +18,12 @@ | |
it { is_expected.to be_a SymEngine::Rational } | ||
its(:to_s) { is_expected.to eq '1/3' } | ||
end | ||
|
||
describe 'parse' do | ||
subject { SymEngine::parse('123 + 321') } | ||
|
||
it { is_expected.to be_a SymEngine::Integer } | ||
it { is_expected.to eq 444 } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What will be if there's erroneous/unparseable input? (And, BTW, what input, if any is considered erroneous or unparseable by symengine?) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @zverok I did think about that. In C++ code it will throw errors for unparseable code. Checking that may almost be equivalent to doing the parsing. There are 4 errors,
Catching the exceptions from the C++ code and throwing ruby exceptions will be covered in the weeks 9 and 10. So this issue will be solved then. As of now, I wanted the tests to merely confirm that the Ruby wrapper is communicating successfully with the cwrapper. Actually the same idea was behind the matrix wrapper tests. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it. I just always became suspicious when I see tests for success and not tests for fail :) context "When there is parsing error" do
# TODO: will be covered on weeks 9-10
end Though, I'm not insisting, currently. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a quite nice way to make it clear! I'll keep this as it is, because week 9 is just one week away from now, probably I will start working on it even earlier. |
||
end | ||
|
||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since these specs act as documentation, can you add more strings for parsing?
eg.
x + (y * 3 - 5)
x ** y + f(x)
sin(x) + cos(y) / 2
1 / 2 + 3 / 2
1 + 2 * 2
tan(0) - sqrt(2)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to add a few more to this list
5+-3
5--3
All Without spaces
And
5++3
or something like this to raise an error.