From a7bc3801f94891880a90b2974dfbadc9e9f8c2ee Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 5 Jan 2007 20:52:12 +0000 Subject: r20567: Print proper errors with filename and line numbers in ParseExpr() (This used to be commit f5dc1b47ecf18068a47f8f68016463ef4a55dc03) --- source4/pidl/tests/util.pl | 68 ++++++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 32 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/util.pl b/source4/pidl/tests/util.pl index 4c002458ea..1dde97b192 100755 --- a/source4/pidl/tests/util.pl +++ b/source4/pidl/tests/util.pl @@ -3,9 +3,10 @@ # Published under the GNU General Public License use strict; -use Test::More tests => 53; +use Test::More tests => 55; use FindBin qw($RealBin); -use lib "$RealBin/../lib"; +use lib "$RealBin"; +use Util; use Parse::Pidl::Util; # has_property() @@ -49,38 +50,41 @@ ok(property_matches({PROPERTIES => {x => "data"}}, "x", "^([dat]+)\$")); # ParseExpr() #is("", ParseExpr("", {})); -is("a", ParseExpr("a", {"b" => "2"})); -is("2", ParseExpr("a", {"a" => "2"})); -is("2 * 2", ParseExpr("a*a", {"a" => "2"})); +is("a", ParseExpr("a", {"b" => "2"}, undef)); +is("2", ParseExpr("a", {"a" => "2"}, undef)); +is("2 * 2", ParseExpr("a*a", {"a" => "2"}, undef)); is("r->length + r->length", - ParseExpr("length+length", {"length" => "r->length"})); + ParseExpr("length+length", {"length" => "r->length"}, undef)); is("2 / 2 * (r->length)", ParseExpr("constant/constant*(len)", {"constant" => "2", - "len" => "r->length"})); + "len" => "r->length"}, undef)); is("2 + 2 - r->length", ParseExpr("constant+constant-len", {"constant" => "2", - "len" => "r->length"})); -is("*r->length", ParseExpr("*len", { "len" => "r->length"})); -is("**r->length", ParseExpr("**len", { "len" => "r->length"})); -is("r->length & 2", ParseExpr("len&2", { "len" => "r->length"})); -is("&r->length", ParseExpr("&len", { "len" => "r->length"})); -is("calc()", ParseExpr("calc()", { "foo" => "2"})); -is("calc(2 * 2)", ParseExpr("calc(foo * 2)", { "foo" => "2"})); -is("strlen(\"data\")", ParseExpr("strlen(foo)", { "foo" => "\"data\""})); -is("strlen(\"data\", 4)", ParseExpr("strlen(foo, 4)", { "foo" => "\"data\""})); -is("foo / bar", ParseExpr("foo / bar", { "bla" => "\"data\""})); -is("r->length % 2", ParseExpr("len%2", { "len" => "r->length"})); -is("r->length == 2", ParseExpr("len==2", { "len" => "r->length"})); -is("r->length != 2", ParseExpr("len!=2", { "len" => "r->length"})); -is("pr->length", ParseExpr("pr->length", { "p" => "r"})); -is("r->length", ParseExpr("p->length", { "p" => "r"})); -is("_foo / bla32", ParseExpr("_foo / bla32", { "bla" => "\"data\""})); -is("foo.bar.blah", ParseExpr("foo.blah", { "foo" => "foo.bar"})); -is("\"bla\"", ParseExpr("\"bla\"", {})); -is("1 << 2", ParseExpr("1 << 2", {})); -is("1 >> 2", ParseExpr("1 >> 2", {})); -is("0x200", ParseExpr("0x200", {})); -is("2?3:0", ParseExpr("2?3:0", {})); -is("~0", ParseExpr("~0", {})); -is("b->a->a", ParseExpr("a->a->a", {"a" => "b"})); -is("b.a.a", ParseExpr("a.a.a", {"a" => "b"})); + "len" => "r->length"}, undef)); +is("*r->length", ParseExpr("*len", { "len" => "r->length"}, undef)); +is("**r->length", ParseExpr("**len", { "len" => "r->length"}, undef)); +is("r->length & 2", ParseExpr("len&2", { "len" => "r->length"}, undef)); +is("&r->length", ParseExpr("&len", { "len" => "r->length"}, undef)); +is("calc()", ParseExpr("calc()", { "foo" => "2"}, undef)); +is("calc(2 * 2)", ParseExpr("calc(foo * 2)", { "foo" => "2"}, undef)); +is("strlen(\"data\")", ParseExpr("strlen(foo)", { "foo" => "\"data\""}, undef)); +is("strlen(\"data\", 4)", ParseExpr("strlen(foo, 4)", { "foo" => "\"data\""}, undef)); +is("foo / bar", ParseExpr("foo / bar", { "bla" => "\"data\""}, undef)); +is("r->length % 2", ParseExpr("len%2", { "len" => "r->length"}, undef)); +is("r->length == 2", ParseExpr("len==2", { "len" => "r->length"}, undef)); +is("r->length != 2", ParseExpr("len!=2", { "len" => "r->length"}, undef)); +is("pr->length", ParseExpr("pr->length", { "p" => "r"}, undef)); +is("r->length", ParseExpr("p->length", { "p" => "r"}, undef)); +is("_foo / bla32", ParseExpr("_foo / bla32", { "bla" => "\"data\""}, undef)); +is("foo.bar.blah", ParseExpr("foo.blah", { "foo" => "foo.bar"}, undef)); +is("\"bla\"", ParseExpr("\"bla\"", {}, undef)); +is("1 << 2", ParseExpr("1 << 2", {}, undef)); +is("1 >> 2", ParseExpr("1 >> 2", {}, undef)); +is("0x200", ParseExpr("0x200", {}, undef)); +is("2?3:0", ParseExpr("2?3:0", {}, undef)); +is("~0", ParseExpr("~0", {}, undef)); +is("b->a->a", ParseExpr("a->a->a", {"a" => "b"}, undef)); +is("b.a.a", ParseExpr("a.a.a", {"a" => "b"}, undef)); + +test_errors("nofile:0: Parse error in `~' near `~'\n", sub { + is(undef, ParseExpr("~", {}, {FILE => "nofile", LINE => 0})); }); -- cgit