summaryrefslogtreecommitdiff
path: root/i/marvin/src/interpreter/test_interpreter.cc
diff options
context:
space:
mode:
authorschodet2006-04-11 19:08:35 +0000
committerschodet2006-04-11 19:08:35 +0000
commitaa023b1a9f1a84323a81c8674d46a1d5a0d39629 (patch)
treec1a39a1ddd0f13432c1a26c3cefab41ec4bdb9ef /i/marvin/src/interpreter/test_interpreter.cc
parentfe8085484038b83d431459ac7fc3980cbbac9137 (diff)
Correction d'une erreur dans le bad_any_cast.
Ajout du support de la notation exponentielle dans le parser. Ajout du support du parser dans l'interpreter.
Diffstat (limited to 'i/marvin/src/interpreter/test_interpreter.cc')
-rw-r--r--i/marvin/src/interpreter/test_interpreter.cc36
1 files changed, 30 insertions, 6 deletions
diff --git a/i/marvin/src/interpreter/test_interpreter.cc b/i/marvin/src/interpreter/test_interpreter.cc
index 8c2eb88..d51357d 100644
--- a/i/marvin/src/interpreter/test_interpreter.cc
+++ b/i/marvin/src/interpreter/test_interpreter.cc
@@ -68,9 +68,23 @@ class TestInterpreter
std::cout << ' ' << e.what () << std::endl;
}
}
+ void interpretString (const std::string &s)
+ {
+ try
+ {
+ std::cout << "interpret dry \"" << s << "\"" << std::endl;
+ t.interpretString (s, true);
+ std::cout << "interpret \"" << s << "\"" << std::endl;
+ t.interpretString (s);
+ }
+ catch (const std::exception &e)
+ {
+ // Do not use std::cerr as there should be only normal errors.
+ std::cout << ' ' << e.what () << std::endl;
+ }
+ }
int main (void)
{
- Interpreter::Args a[4];
// Add functions.
t.add ("a", Interpreter::memFunc (*this, &TestInterpreter::funcA));
t.add ("b", Interpreter::memFunc (*this, &TestInterpreter::funcB));
@@ -78,6 +92,7 @@ class TestInterpreter
t.add ("d", Interpreter::memFunc (*this, &TestInterpreter::funcD));
t.add ("e", Interpreter::memFunc (*this, &TestInterpreter::funcE));
// Make argument lists.
+ Interpreter::Args a[4];
a[1].push_back (71117);
a[2].push_back (std::string ("robert"));
a[3].push_back (42);
@@ -87,11 +102,20 @@ class TestInterpreter
call ("unknown", a[0]);
for (unsigned int i = 0; i < sizeof (a) / sizeof (a[0]); ++i)
{
- call ("a", a[i]);
- call ("b", a[i]);
- call ("c", a[i]);
- call ("d", a[i]);
- call ("e", a[i]);
+ for (char f = 'a'; f <= 'e'; f++)
+ {
+ call (std::string (1, f), a[i]);
+ }
+ }
+ // Now, with the interpreter.
+ interpretString ("a = 42");
+ interpretString ("42");
+ for (char f = 'a'; f <= 'e'; f++)
+ {
+ interpretString (std::string (1, f));
+ interpretString (std::string (1, f) + " 42 ");
+ interpretString (std::string (1, f) + " \"robert\";; ");
+ interpretString (std::string (1, f) + " 757 \"tintin\" 0.3141516e+1");
}
return 0;
}