summaryrefslogtreecommitdiff
path: root/src/sexpr/parser_test.cpp
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2014-10-29 14:56:55 -0700
committerBen Longbons <b.r.longbons@gmail.com>2014-10-29 14:56:55 -0700
commit1a00fe4ea75924bfe594c4d92073cc95eaa2f32d (patch)
treea6e8992e0821a998236a4dfb5d6f6194a0b7ce97 /src/sexpr/parser_test.cpp
parent469991120bcf550b6e2124203103876b6b7be918 (diff)
downloadtmwa-1a00fe4ea75924bfe594c4d92073cc95eaa2f32d.tar.gz
tmwa-1a00fe4ea75924bfe594c4d92073cc95eaa2f32d.tar.bz2
tmwa-1a00fe4ea75924bfe594c4d92073cc95eaa2f32d.tar.xz
tmwa-1a00fe4ea75924bfe594c4d92073cc95eaa2f32d.zip
Item AST
Diffstat (limited to 'src/sexpr/parser_test.cpp')
-rw-r--r--src/sexpr/parser_test.cpp22
1 files changed, 3 insertions, 19 deletions
diff --git a/src/sexpr/parser_test.cpp b/src/sexpr/parser_test.cpp
index 8619c15..bbaf5eb 100644
--- a/src/sexpr/parser_test.cpp
+++ b/src/sexpr/parser_test.cpp
@@ -27,27 +27,11 @@
namespace tmwa
{
-static
-io::FD string_pipe(ZString sz)
-{
- io::FD rfd, wfd;
- if (-1 == io::FD::pipe(rfd, wfd))
- return io::FD();
- if (sz.size() != wfd.write(sz.c_str(), sz.size()))
- {
- rfd.close();
- wfd.close();
- return io::FD();
- }
- wfd.close();
- return rfd;
-}
-
TEST(sexpr, parser)
{
sexpr::SExpr s;
io::LineSpan span;
- sexpr::Lexer lexer("<parser-test1>"_s, string_pipe(" foo( ) 123\"\" \n"_s));
+ sexpr::Lexer lexer(io::from_string, "<parser-test1>"_s, " foo( ) 123\"\" \n"_s);
EXPECT_TRUE(sexpr::parse(lexer, s));
EXPECT_EQ(s._type, sexpr::TOKEN);
@@ -72,7 +56,7 @@ TEST(sexpr, parser)
TEST(sexpr, parselist)
{
sexpr::SExpr s;
- sexpr::Lexer lexer("<parser-test1>"_s, string_pipe("(foo)(bar)\n"_s));
+ sexpr::Lexer lexer(io::from_string, "<parser-test1>"_s, "(foo)(bar)\n"_s);
EXPECT_TRUE(sexpr::parse(lexer, s));
EXPECT_EQ(s._type, sexpr::LIST);
@@ -108,7 +92,7 @@ TEST(sexpr, parsebad)
{
sexpr::SExpr s;
io::LineSpan span;
- sexpr::Lexer lexer("<parse-bad>"_s, string_pipe(bad));
+ sexpr::Lexer lexer(io::from_string, "<parse-bad>"_s, bad);
EXPECT_FALSE(sexpr::parse(lexer, s));
EXPECT_EQ(lexer.peek(), sexpr::TOK_ERROR);
}