From 14b909b25dec8e68f7bcb35e89ce503c5f12967c Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 27 Aug 2010 19:55:14 +0200 Subject: Reimplement state stack not to move elements Add another recursive parsing test that forces second allocation in the stack. --- tests/cxx/parser/recursive/driver.cxx | 88 ++++++++++++++++++++++- tests/cxx/parser/recursive/makefile | 13 +++- tests/cxx/parser/recursive/test-001.std | 123 ++++++++++++++++++++++++++++++++ tests/cxx/parser/recursive/test-001.xml | 50 +++++++++++++ tests/cxx/parser/recursive/test.xsd | 29 +++++++- 5 files changed, 297 insertions(+), 6 deletions(-) create mode 100644 tests/cxx/parser/recursive/test-001.std create mode 100644 tests/cxx/parser/recursive/test-001.xml (limited to 'tests') diff --git a/tests/cxx/parser/recursive/driver.cxx b/tests/cxx/parser/recursive/driver.cxx index f961d76..bcbbd2e 100644 --- a/tests/cxx/parser/recursive/driver.cxx +++ b/tests/cxx/parser/recursive/driver.cxx @@ -91,6 +91,78 @@ struct indir_pimpl: indir_type_pskel } }; +struct a_pimpl: a_pskel +{ + virtual void + pre () + { + cout << "a::pre" << endl; + } + + virtual void + a () + { + cout << "a::a" << endl; + } + + virtual void + b () + { + cout << "a::b" << endl; + } + +#ifdef XSDE_STL + virtual void + name (string const& n) + { + cout << "a::name: " << n << endl; + } +#else + virtual void + name (char* n) + { + cout << "a::name: " << n << endl; + delete[] n; + } +#endif + + virtual void + post_a () + { + cout << "a::post" << endl; + } +}; + +struct b_pimpl: b_pskel +{ + virtual void + pre () + { + cout << "b::pre" << endl; + } + +#ifdef XSDE_STL + virtual void + name (string const& n) + { + cout << "b::name: " << n << endl; + } +#else + virtual void + name (char* n) + { + cout << "b::name: " << n << endl; + delete[] n; + } +#endif + + virtual void + post_b () + { + cout << "b::post" << endl; + } +}; + struct test_pimpl: test_type_pskel { virtual void @@ -105,6 +177,12 @@ struct test_pimpl: test_type_pskel cout << "test::sub" << endl; } + virtual void + a () + { + cout << "test::a" << endl; + } + #ifdef XSDE_STL virtual void name (string const& n) @@ -143,11 +221,19 @@ main (int argc, char* argv[]) sub_pimpl sub_p; indir_pimpl indir_p; + + a_pimpl a_p; + b_pimpl b_p; + test_pimpl test_p; sub_p.parsers (string_p, sub_p, indir_p, sub_p); indir_p.parsers (string_p, sub_p); - test_p.parsers (string_p, sub_p); + + a_p.parsers (string_p, a_p, b_p); + b_p.parsers (string_p); + + test_p.parsers (string_p, sub_p, a_p); xml_schema::document_pimpl doc_p (test_p, "test"); diff --git a/tests/cxx/parser/recursive/makefile b/tests/cxx/parser/recursive/makefile index 7b9d36f..79307b7 100644 --- a/tests/cxx/parser/recursive/makefile +++ b/tests/cxx/parser/recursive/makefile @@ -8,6 +8,8 @@ include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make xsd := test.xsd cxx := driver.cxx +tests := 000 001 + obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=-pskel.o)) dep := $(obj:.o=.o.d) @@ -43,9 +45,14 @@ $(out_base)/: $(driver) # Test. # -$(test): driver := $(driver) -$(test): $(driver) $(src_base)/test-000.xml $(src_base)/test-000.std - $(call message,test $$1,$$1 $(src_base)/test-000.xml | diff -u $(src_base)/test-000.std -,$(driver)) +test_targets := $(addprefix $(out_base)/.test-,$(tests)) + +$(test): $(test_targets) +$(test_targets): driver := $(driver) + +.PHONY: $(out_base)/.test-% +$(out_base)/.test-%: $(driver) $(src_base)/test.xsd $(src_base)/test-%.xml $(src_base)/test-%.std + $(call message,test $(out_base)/$*,$(driver) $(src_base)/test-$*.xml | diff -u $(src_base)/test-$*.std -) # Dist. diff --git a/tests/cxx/parser/recursive/test-001.std b/tests/cxx/parser/recursive/test-001.std new file mode 100644 index 0000000..9acdc4c --- /dev/null +++ b/tests/cxx/parser/recursive/test-001.std @@ -0,0 +1,123 @@ +test::pre +test::name: testName +a::pre +a::name: 1 +b::pre +b::name: b1 +b::post +a::b +a::pre +a::name: 2 +b::pre +b::name: b1 +b::post +a::b +a::pre +a::name: 3 +b::pre +b::name: b3 +b::post +a::b +a::pre +a::name: 4 +b::pre +b::name: b4 +b::post +a::b +a::pre +a::name: 5 +b::pre +b::name: b5 +b::post +a::b +a::pre +a::name: 6 +b::pre +b::name: b6 +b::post +a::b +a::pre +a::name: 7 +b::pre +b::name: b7 +b::post +a::b +a::pre +a::name: 8 +b::pre +b::name: b8 +b::post +a::b +a::pre +a::name: 9 +b::pre +b::name: b9 +b::post +a::b +a::pre +a::name: 10 +b::pre +b::name: b10 +b::post +a::b +a::pre +a::name: 11 +b::pre +b::name: b11 +b::post +a::b +a::pre +a::name: 12 +b::pre +b::name: b12 +b::post +a::b +a::pre +a::name: 13 +b::pre +b::name: b13 +b::post +a::b +a::pre +a::name: 14 +b::pre +b::name: b14 +b::post +a::b +a::pre +a::name: 15 +b::pre +b::name: b15 +b::post +a::b +a::post +a::a +a::post +a::a +a::post +a::a +a::post +a::a +a::post +a::a +a::post +a::a +a::post +a::a +a::post +a::a +a::post +a::a +a::post +a::a +a::post +a::a +a::post +a::a +a::post +a::a +a::post +a::a +a::post +test::a +test::post diff --git a/tests/cxx/parser/recursive/test-001.xml b/tests/cxx/parser/recursive/test-001.xml new file mode 100644 index 0000000..d90bf23 --- /dev/null +++ b/tests/cxx/parser/recursive/test-001.xml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/cxx/parser/recursive/test.xsd b/tests/cxx/parser/recursive/test.xsd index 33e1d2d..0723ca2 100644 --- a/tests/cxx/parser/recursive/test.xsd +++ b/tests/cxx/parser/recursive/test.xsd @@ -1,5 +1,7 @@ + + @@ -16,10 +18,33 @@ + + + + + + + + + + + + + + + + + + + + + + - + - + + -- cgit v1.1