bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

FYI: tests: fix %printer


From: Akim Demaille
Subject: FYI: tests: fix %printer
Date: Tue, 4 May 2010 15:28:07 +0200

Installed in master, makes no sense in 2.5.

We need to check that %printer/%destructor are about "existing" type tags.

From f5da8149a27834cbce2839d527f7f34430125de6 Mon Sep 17 00:00:00 2001
From: Akim Demaille <address@hidden>
Date: Thu, 29 Apr 2010 12:35:13 +0200
Subject: tests: fix %printer.

Currently, there is no check that %printer ... <foo> (nor
%destructor) is about an existing <foo> type.  This C++ test had
it wrong (<::std::string> vs. <std::string>).

        * tests/c++.at (AT_CHECK_VARIANTS): In list.yy, redefine the
        pretty-printing of lists into something better for parser traces.
        Update the expected output.
        Fix correspondance between %type/%token and %printer.
---
 ChangeLog    |   12 ++++++++++++
 tests/c++.at |   24 ++++++++++++------------
 2 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 3b3cd4e..8340bfd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
 2010-05-04  Akim Demaille  <address@hidden>
 
+       tests: fix %printer.
+       Currently, there is no check that %printer ... <foo> (nor
+       %destructor) is about an existing <foo> type.  This C++ test had
+       it wrong (<::std::string> vs. <std::string>).
+
+       * tests/c++.at (AT_CHECK_VARIANTS): In list.yy, redefine the
+       pretty-printing of lists into something better for parser traces.
+       Update the expected output.
+       Fix correspondance between %type/%token and %printer.
+
+2010-05-04  Akim Demaille  <address@hidden>
+
        lalr1.cc: location_type: make sure we don't depend on loc.(begin|end).
        * tests/calc.at (Span): Instead of begin/end, as in the built-in
        location class, use first and last.
diff --git a/tests/c++.at b/tests/c++.at
index bcd9800..8377bfe 100644
--- a/tests/c++.at
+++ b/tests/c++.at
@@ -46,9 +46,7 @@ typedef std::list<std::string> strings_type;
 
 %code // code for the .cc file
 {
-#include <algorithm>
 #include <iostream>
-#include <iterator>
 #include <sstream>
 
   static
@@ -66,9 +64,14 @@ typedef std::list<std::string> strings_type;
     std::ostream&
     operator<<(std::ostream& o, const strings_type& s)
     {
-      std::copy(s.begin(), s.end(),
-                std::ostream_iterator<strings_type::value_type>(o, "\n"));
-      return o;
+      o << '(';
+      for (strings_type::const_iterator i = s.begin(); i != s.end (); ++i)
+        {
+          if (i != s.begin ())
+            o << ", ";
+          o << *i;
+        }
+      return o << ')';
     }
   }
 
@@ -84,11 +87,11 @@ typedef std::list<std::string> strings_type;
   }
 }
 
-%token <std::string> TEXT;
+%token <::std::string> TEXT;
 %token <int> NUMBER;
 %token END_OF_FILE 0;
 
-%type <std::string> item;
+%type <::std::string> item;
 // Using the template type to exercize its parsing.
 // Starting with :: to ensure we don't output "<::" which starts by the
 // digraph for the left square bracket.
@@ -99,7 +102,7 @@ typedef std::list<std::string> strings_type;
 %%
 
 result:
-  list          { std::cout << $][1; }
+  list          { std::cout << $][1 << std::endl; }
 ;
 
 list:
@@ -186,10 +189,7 @@ main (void)
 AT_BISON_CHECK([-o list.cc list.yy])
 AT_COMPILE_CXX([list])
 AT_CHECK([./list], 0,
-[0
-1
-2
-4
+         [(0, 1, 2, 4)
 ])
 
 AT_CLEANUP
-- 
1.7.0.5







reply via email to

[Prev in Thread] Current Thread [Next in Thread]