mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 04:13:03 +00:00
tests: prepare a test for automove
The 'Variants' tests are well suited to check support for move, and in
particular for the forthcoming automove feature. But the tests were
written to show the best practice in C++98, using swap:
list "," item { std::swap ($$, $1); $$.push_back ($3); }
This cannot work with std::move. So, make this example simpler, based
on regular assignment instead of swap, which is a regression for
C++98 (as the new traces show), but will be an improvement for modern
C++ with automove.
* tests/c++.at (Variants): Stop using swap.
We don't generate a header file, so remove the 'require' code section.
Adjust expectations.
This commit is contained in:
35
tests/c++.at
35
tests/c++.at
@@ -214,13 +214,6 @@ AT_DATA_GRAMMAR([list.y],
|
||||
]m4_bpatsubst([$1], [\\n], [
|
||||
])[
|
||||
|
||||
%code requires // code for the .hh file
|
||||
{
|
||||
#include <vector>
|
||||
#include <string>
|
||||
typedef std::vector<std::string> strings_type;
|
||||
}
|
||||
|
||||
%code top // code for the .cc file.
|
||||
{
|
||||
#include <cstdlib> // abort, getenv
|
||||
@@ -295,12 +288,12 @@ result:
|
||||
|
||||
list:
|
||||
item { $$.push_back ($][1); }
|
||||
| list "," item { std::swap ($$, $][1); $$.push_back ($][3); }
|
||||
| list error { std::swap ($$, $][1); }
|
||||
| list "," item { $$ = $][1; $$.push_back ($][3); }
|
||||
| list error { $$ = $][1; }
|
||||
;
|
||||
|
||||
item:
|
||||
TEXT { std::swap ($$, $][1); }
|
||||
TEXT { $$ = $][1; }
|
||||
| NUMBER { if ($][1 == 3) YYERROR; else $$ = to_string ($][1); }
|
||||
;
|
||||
%%
|
||||
@@ -369,26 +362,26 @@ AT_FULL_COMPILE([list])
|
||||
AT_PARSER_CHECK([./list], 0,
|
||||
[[(0, 1, 2, 4, 6)
|
||||
]],
|
||||
[[Destroy: ""
|
||||
[[Destroy: "0"
|
||||
Destroy: "0"
|
||||
Destroy: 1
|
||||
Destroy: "1"
|
||||
Destroy: ()
|
||||
Destroy: ""
|
||||
Destroy: (0)
|
||||
Destroy: "2"
|
||||
Destroy: ()
|
||||
Destroy: "2"
|
||||
Destroy: (0, 1)
|
||||
Destroy: ""
|
||||
Destroy: 3
|
||||
Destroy: ()
|
||||
Destroy: ""
|
||||
Destroy: (0, 1, 2)
|
||||
Destroy: "4"
|
||||
Destroy: ()
|
||||
Destroy: ()
|
||||
Destroy: "4"
|
||||
Destroy: (0, 1, 2)
|
||||
Destroy: (0, 1, 2, 4)
|
||||
Destroy: 5
|
||||
Destroy: ()
|
||||
Destroy: ""
|
||||
Destroy: (0, 1, 2, 4)
|
||||
Destroy: "6"
|
||||
Destroy: ()
|
||||
Destroy: "6"
|
||||
Destroy: (0, 1, 2, 4)
|
||||
Destroy: (0, 1, 2, 4, 6)
|
||||
]])
|
||||
])
|
||||
|
||||
Reference in New Issue
Block a user