mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-21 18:23:03 +00:00
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.
This commit is contained in:
12
ChangeLog
12
ChangeLog
@@ -1,3 +1,15 @@
|
|||||||
|
2010-05-04 Akim Demaille <demaille@gostai.com>
|
||||||
|
|
||||||
|
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 <demaille@gostai.com>
|
2010-05-04 Akim Demaille <demaille@gostai.com>
|
||||||
|
|
||||||
lalr1.cc: location_type: make sure we don't depend on loc.(begin|end).
|
lalr1.cc: location_type: make sure we don't depend on loc.(begin|end).
|
||||||
|
|||||||
24
tests/c++.at
24
tests/c++.at
@@ -46,9 +46,7 @@ typedef std::list<std::string> strings_type;
|
|||||||
|
|
||||||
%code // code for the .cc file
|
%code // code for the .cc file
|
||||||
{
|
{
|
||||||
#include <algorithm>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <iterator>
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
static
|
static
|
||||||
@@ -66,9 +64,14 @@ typedef std::list<std::string> strings_type;
|
|||||||
std::ostream&
|
std::ostream&
|
||||||
operator<<(std::ostream& o, const strings_type& s)
|
operator<<(std::ostream& o, const strings_type& s)
|
||||||
{
|
{
|
||||||
std::copy(s.begin(), s.end(),
|
o << '(';
|
||||||
std::ostream_iterator<strings_type::value_type>(o, "\n"));
|
for (strings_type::const_iterator i = s.begin(); i != s.end (); ++i)
|
||||||
return o;
|
{
|
||||||
|
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 <int> NUMBER;
|
||||||
%token END_OF_FILE 0;
|
%token END_OF_FILE 0;
|
||||||
|
|
||||||
%type <std::string> item;
|
%type <::std::string> item;
|
||||||
// Using the template type to exercize its parsing.
|
// Using the template type to exercize its parsing.
|
||||||
// Starting with :: to ensure we don't output "<::" which starts by the
|
// Starting with :: to ensure we don't output "<::" which starts by the
|
||||||
// digraph for the left square bracket.
|
// digraph for the left square bracket.
|
||||||
@@ -99,7 +102,7 @@ typedef std::list<std::string> strings_type;
|
|||||||
%%
|
%%
|
||||||
|
|
||||||
result:
|
result:
|
||||||
list { std::cout << $][1; }
|
list { std::cout << $][1 << std::endl; }
|
||||||
;
|
;
|
||||||
|
|
||||||
list:
|
list:
|
||||||
@@ -186,10 +189,7 @@ main (void)
|
|||||||
AT_BISON_CHECK([-o list.cc list.yy])
|
AT_BISON_CHECK([-o list.cc list.yy])
|
||||||
AT_COMPILE_CXX([list])
|
AT_COMPILE_CXX([list])
|
||||||
AT_CHECK([./list], 0,
|
AT_CHECK([./list], 0,
|
||||||
[0
|
[(0, 1, 2, 4)
|
||||||
1
|
|
||||||
2
|
|
||||||
4
|
|
||||||
])
|
])
|
||||||
|
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|||||||
Reference in New Issue
Block a user