Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r61290 - in trunk/libs/spirit/example/scheme: . test test/scheme
From: joel_at_[hidden]
Date: 2010-04-15 08:49:31


Author: djowel
Date: 2010-04-15 08:49:30 EDT (Thu, 15 Apr 2010)
New Revision: 61290
URL: http://svn.boost.org/trac/boost/changeset/61290

Log:
jamfile
Added:
   trunk/libs/spirit/example/scheme/test/Jamfile (contents, props changed)
Text files modified:
   trunk/libs/spirit/example/scheme/scheme_interpreter.hpp | 6 ++--
   trunk/libs/spirit/example/scheme/test/scheme/scheme_test3.cpp | 3 +
   trunk/libs/spirit/example/scheme/test/utree_test.cpp | 56 ++++++++++++++++++++--------------------
   3 files changed, 33 insertions(+), 32 deletions(-)

Modified: trunk/libs/spirit/example/scheme/scheme_interpreter.hpp
==============================================================================
--- trunk/libs/spirit/example/scheme/scheme_interpreter.hpp (original)
+++ trunk/libs/spirit/example/scheme/scheme_interpreter.hpp 2010-04-15 08:49:30 EDT (Thu, 15 Apr 2010)
@@ -30,7 +30,7 @@
 
     typedef std::list<function> actor_list;
     typedef boost::iterator_range<utree const*> args_type;
- typedef boost::function<utree(args_type args)> actor_function;
+ typedef boost::function<utree(args_type args)> stored_function;
 
     ///////////////////////////////////////////////////////////////////////////
     // actor
@@ -89,11 +89,11 @@
     ///////////////////////////////////////////////////////////////////////////
     struct function : actor<function>
     {
- actor_function f;
+ stored_function f;
         function()
           : f() {}
 
- function(actor_function const& f)
+ function(stored_function const& f)
           : f(f)
         {
             BOOST_ASSERT(!f.empty());

Added: trunk/libs/spirit/example/scheme/test/Jamfile
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/example/scheme/test/Jamfile 2010-04-15 08:49:30 EDT (Thu, 15 Apr 2010)
@@ -0,0 +1,27 @@
+#==============================================================================
+# Copyright (c) 2001-2007 Joel de Guzman
+#
+# Distributed under the Boost Software License, Version 1.0. (See accompanying
+# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+#==============================================================================
+project spirit-scheme-tests
+ : requirements <toolset>gcc:<c++-template-depth>300
+ :
+ :
+ ;
+
+# bring in rules for testing
+import testing ;
+
+{
+ test-suite spirit_v2 :
+
+ # run Qi tests
+ [ run utree_test.cpp : : : : ]
+
+ ;
+}
+
+
+
+

Modified: trunk/libs/spirit/example/scheme/test/scheme/scheme_test3.cpp
==============================================================================
--- trunk/libs/spirit/example/scheme/test/scheme/scheme_test3.cpp (original)
+++ trunk/libs/spirit/example/scheme/test/scheme/scheme_test3.cpp 2010-04-15 08:49:30 EDT (Thu, 15 Apr 2010)
@@ -6,6 +6,8 @@
 =============================================================================*/
 #include <boost/config/warning_disable.hpp>
 
+#include "../../input/sexpr.hpp"
+#include "../../input/parse_sexpr_impl.hpp"
 #include "../../scheme_compiler.hpp"
 #include "../../utree_io.hpp"
 
@@ -15,7 +17,6 @@
 int main()
 {
     using scheme::interpreter;
- using scheme::_1;
     using scheme::utree;
 
     utree src = "(define (factorial n) (if (<= n 0) 1 (* n (factorial (- n 1)))))";

Modified: trunk/libs/spirit/example/scheme/test/utree_test.cpp
==============================================================================
--- trunk/libs/spirit/example/scheme/test/utree_test.cpp (original)
+++ trunk/libs/spirit/example/scheme/test/utree_test.cpp 2010-04-15 08:49:30 EDT (Thu, 15 Apr 2010)
@@ -11,13 +11,13 @@
 #include "../utree_operators.hpp"
 #include "../utree_io.hpp"
 #include <iostream>
+#include <sstream>
 
-inline std::ostream& println(std::ostream& out, scheme::utree const& val)
+inline void check(scheme::utree const& val, std::string expected)
 {
- if (val.which() == scheme::utree_type::list_type)
- out << "size:" << val.size() << " ";
- out << val << std::endl;
- return out;
+ std::stringstream s;
+ s << val;
+ BOOST_ASSERT(s.str() == expected);
 }
 
 int main()
@@ -32,33 +32,33 @@
 
     {
         utree val;
- println(std::cout, val);
+ check(val, "<nil>");
     }
 
     {
         utree val(true);
- println(std::cout, val);
+ check(val, "true");
     }
 
     {
         utree val(123);
- println(std::cout, val);
+ check(val, "123");
     }
 
     {
         utree val(123.456);
- println(std::cout, val);
+ check(val, "123.456");
     }
 
     {
         utree val("Hello, World");
- println(std::cout, val);
+ check(val, "\"Hello, World\"");
         utree val2;
         val2 = val;
- println(std::cout, val2);
+ check(val2, "\"Hello, World\"");
         utree val3("Hello, World. Chuckie is back!!!");
         val = val3;
- println(std::cout, val);
+ check(val, "\"Hello, World. Chuckie is back!!!\"");
 
         utree val4("Apple");
         utree val5("Apple");
@@ -78,35 +78,35 @@
         val2.push_back("Mah Doggie");
         val.push_back(val2);
         BOOST_ASSERT(val.size() == 3);
- println(std::cout, val);
- println(std::cout, val.front());
+ check(val, "( 123 \"Chuckie\" ( 123.456 \"Mah Doggie\" ) )");
+ check(val.front(), "123");
 
         utree val3;
         val3.swap(val);
         BOOST_ASSERT(val3.size() == 3);
- println(std::cout, val);
+ check(val, "<nil>");
         val3.swap(val);
- println(std::cout, val);
+ check(val, "( 123 \"Chuckie\" ( 123.456 \"Mah Doggie\" ) )");
         val.push_back("another string");
         BOOST_ASSERT(val.size() == 4);
- println(std::cout, val);
+ check(val, "( 123 \"Chuckie\" ( 123.456 \"Mah Doggie\" ) \"another string\" )");
         val.pop_front();
- println(std::cout, val);
+ check(val, "( \"Chuckie\" ( 123.456 \"Mah Doggie\" ) \"another string\" )");
         utree::iterator i = val.begin();
         ++++i;
         val.insert(i, "Right in the middle");
         BOOST_ASSERT(val.size() == 4);
- println(std::cout, val);
+ check(val, "( \"Chuckie\" ( 123.456 \"Mah Doggie\" ) \"Right in the middle\" \"another string\" )");
         val.pop_back();
- println(std::cout, val);
+ check(val, "( \"Chuckie\" ( 123.456 \"Mah Doggie\" ) \"Right in the middle\" )");
         BOOST_ASSERT(val.size() == 3);
         utree::iterator it = val.end(); --it;
         val.erase(it);
- println(std::cout, val);
+ check(val, "( \"Chuckie\" ( 123.456 \"Mah Doggie\" ) )");
         BOOST_ASSERT(val.size() == 2);
 
         val.insert(val.begin(), val2.begin(), val2.end());
- println(std::cout, val);
+ check(val, "( 123.456 \"Mah Doggie\" \"Chuckie\" ( 123.456 \"Mah Doggie\" ) )");
         BOOST_ASSERT(val.size() == 4);
     }
 
@@ -117,7 +117,7 @@
         val.insert(val.end(), "Chuckie");
         val.insert(val.end(), "Poly");
         val.insert(val.end(), "Mochi");
- println(std::cout, val);
+ check(val, "( 123 \"Mia\" \"Chuckie\" \"Poly\" \"Mochi\" )");
     }
 
     {
@@ -176,7 +176,7 @@
     { // test references
         utree val(123);
         utree ref(boost::ref(val));
- println(std::cout, ref);
+ check(ref, "123");
         BOOST_ASSERT(ref == utree(123));
 
         val.clear();
@@ -184,7 +184,7 @@
         val.push_back(2);
         val.push_back(3);
         val.push_back(4);
- println(std::cout, ref);
+ check(ref, "( 1 2 3 4 )");
         BOOST_ASSERT(ref[0] == utree(1));
         BOOST_ASSERT(ref[1] == utree(2));
         BOOST_ASSERT(ref[2] == utree(3));
@@ -199,9 +199,9 @@
             utree(123.456)
         };
 
- println(std::cout, vals[0]);
- println(std::cout, vals[1]);
- println(std::cout, vals[2]);
+ check(vals[0], "123");
+ check(vals[1], "\"Hello, World\"");
+ check(vals[2], "123.456");
     }
 
     { // operators


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk