diff options
Diffstat (limited to 'libcutl/tests/compiler')
-rw-r--r-- | libcutl/tests/compiler/cxx-indenter/driver.cxx | 168 | ||||
-rw-r--r-- | libcutl/tests/compiler/cxx-indenter/makefile | 70 | ||||
-rw-r--r-- | libcutl/tests/compiler/cxx-indenter/output.std | 103 | ||||
-rw-r--r-- | libcutl/tests/compiler/makefile | 17 | ||||
-rw-r--r-- | libcutl/tests/compiler/sloc-counter/driver.cxx | 36 | ||||
-rw-r--r-- | libcutl/tests/compiler/sloc-counter/makefile | 70 | ||||
-rw-r--r-- | libcutl/tests/compiler/sloc-counter/test.cxx | 34 | ||||
-rw-r--r-- | libcutl/tests/compiler/sloc-counter/test.std | 36 | ||||
-rw-r--r-- | libcutl/tests/compiler/traversal/driver.cxx | 139 | ||||
-rw-r--r-- | libcutl/tests/compiler/traversal/makefile | 70 | ||||
-rw-r--r-- | libcutl/tests/compiler/traversal/output.std | 16 |
11 files changed, 0 insertions, 759 deletions
diff --git a/libcutl/tests/compiler/cxx-indenter/driver.cxx b/libcutl/tests/compiler/cxx-indenter/driver.cxx deleted file mode 100644 index 665c6ab..0000000 --- a/libcutl/tests/compiler/cxx-indenter/driver.cxx +++ /dev/null @@ -1,168 +0,0 @@ -// file : tests/compiler/cxx-indenter/driver.cxx -// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC -// license : MIT; see accompanying LICENSE file - -#include <fstream> -#include <iostream> - -#include <cutl/compiler/code-stream.hxx> -#include <cutl/compiler/cxx-indenter.hxx> - -using namespace std; -using namespace cutl::compiler; - -int -main () -{ - //std::wostream& os (wcout); - //ostream_filter<cxx_indenter, wchar_t> filt (os); - - std::ostream& os (cout); - ostream_filter<cxx_indenter, char> filt (os); - - os << "if (true)" - << "{" - << "// Hello there" << endl - << "//" << endl - << "a ();" - << "}" - << "else" - << "{" - << "b ();" - << "}"; - - os << "if (true)" << endl - << "// Hello there" << endl - << "//" << endl - << "a ();" - << "else" << endl - << "b ();" - << endl; - - os << "if (false)" - << "{" - << "if (true)" - << "{" - << "// test" << endl - << "}" - << "else" - << "{" - << "// test" << endl - << "b ();" - << "}" - << "}"; - - os << "namespace a" - << "{" - << "void f ();" - << "}" - << "#if defined(__HP_aCC) && __HP_aCC <= 39999" << endl - << "#include <foo.h>" << endl - << "#endif" << endl - << endl - << "namespace b" - << "{" - << "void f ();" - << "}"; - - // Test do-while handling. - // - os << "do" << endl - << "f ();" - << "while (false);" - << endl; - - os << "do" - << "{" - << "f ();" - << "}" - << "while (false);" - << endl; - - os << "do" - << "{" - << "if (f ())" - << "{" - << "g ();" - << "}" - << "}" - << "while (false);" - << endl; - - os << "do" - << "{" - << "do" << endl - << "f ();" - << "while (false);" - << "}" - << "while (false);" - << endl; - - os << "do" - << "{" - << "do" - << "{" - << "f ();" - << "}" - << "while (false);" - << "}" - << "while (false);" - << endl; - - os << "{" - << "f (\"CREATE TABLE \\\"test\\\" (\"" << endl - << "\"'id',\"" << endl - << "\"'name')\");" - << "}"; - - os << "namespace N" - << "{" - << "static int i[] = {{0,\n0},{1,\n1}};" - << "}"; - -/* - @@ TODO: still misindents (if-else association problem) - - os << "{" - << "if (foo != bar)" << endl - << "if (foo (bar))" << endl - << "baz = true;" - << "else" << endl - << "baz = false;" - << "else" << endl - << "biz = true;" - << endl - << "biz = false;" - << "}"; - - os << "{" - << "if (foo != bar)" << endl - << "if (foo (bar))" - << "{" - << "baz = true;" - - << "if (x)" << endl - << "test ();" - << "else" << endl - << "test ();" - << endl - - << "if (x)" << endl - << "if (y)" - << "{" - << "test ();" - << "}" - << "else" - << "{" - << "test ();" - << "}" - - << "}" - << "else" - << "{" - << "test ();" - << "}" - << "biz = false;" - << "}"; -*/ -} diff --git a/libcutl/tests/compiler/cxx-indenter/makefile b/libcutl/tests/compiler/cxx-indenter/makefile deleted file mode 100644 index da5dbe0..0000000 --- a/libcutl/tests/compiler/cxx-indenter/makefile +++ /dev/null @@ -1,70 +0,0 @@ -# file : tests/compiler/cxx-indenter/makefile -# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC -# license : MIT; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../build/bootstrap.make - -cxx_tun := driver.cxx - -# -# -cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o)) -cxx_od := $(cxx_obj:.o=.o.d) - -cutl.l := $(out_root)/cutl/cutl.l -cutl.l.cpp-options := $(out_root)/cutl/cutl.l.cpp-options - -driver := $(out_base)/driver -test := $(out_base)/.test -clean := $(out_base)/.clean - -# Build. -# -$(driver): $(cxx_obj) $(cutl.l) -$(cxx_obj) $(cxx_od): $(cutl.l.cpp-options) - - -$(call include-dep,$(cxx_od)) - - -# Alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) $(src_base)/output.std - $(call message,test $$1,$$1 | diff -u $(src_base)/output.std -,$(driver)) - - -# Clean. -# -$(clean): \ - $(driver).o.clean \ - $(addsuffix .cxx.clean,$(cxx_obj)) \ - $(addsuffix .cxx.clean,$(cxx_od)) - - -# Generated .gitignore. -# -ifeq ($(out_base),$(src_base)) -$(driver): | $(out_base)/.gitignore - -$(out_base)/.gitignore: files := driver -$(clean): $(out_base)/.gitignore.clean - -$(call include,$(bld_root)/git/gitignore.make) -endif - - -# How to. -# -$(call include,$(bld_root)/cxx/o-e.make) -$(call include,$(bld_root)/cxx/cxx-o.make) -$(call include,$(bld_root)/cxx/cxx-d.make) - -# Dependencies. -# -$(call import,$(src_root)/cutl/makefile) diff --git a/libcutl/tests/compiler/cxx-indenter/output.std b/libcutl/tests/compiler/cxx-indenter/output.std deleted file mode 100644 index 79e74f4..0000000 --- a/libcutl/tests/compiler/cxx-indenter/output.std +++ /dev/null @@ -1,103 +0,0 @@ -if (true) -{ - // Hello there - // - a (); -} -else -{ - b (); -} - -if (true) - // Hello there - // - a (); -else - b (); - -if (false) -{ - if (true) - { - // test - } - else - { - // test - b (); - } -} - -namespace a -{ - void f (); -} - -#if defined(__HP_aCC) && __HP_aCC <= 39999 -#include <foo.h> -#endif - -namespace b -{ - void f (); -} - -do - f (); -while (false); - -do -{ - f (); -} -while (false); - -do -{ - if (f ()) - { - g (); - } -} -while (false); - -do -{ - do - f (); - while (false); -} -while (false); - -do -{ - do - { - f (); - } - while (false); -} -while (false); - -{ - f ("CREATE TABLE \"test\" (" - "'id'," - "'name')"); -} - -namespace N -{ - static int i[] = - { - { - 0, - 0 - }, - { - 1, - 1 - } - }; -} - diff --git a/libcutl/tests/compiler/makefile b/libcutl/tests/compiler/makefile deleted file mode 100644 index 11506fd..0000000 --- a/libcutl/tests/compiler/makefile +++ /dev/null @@ -1,17 +0,0 @@ -# file : tests/compiler/makefile -# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC -# license : MIT; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../build/bootstrap.make - -tests := cxx-indenter sloc-counter traversal - -default := $(out_base)/ -test := $(out_base)/.test -clean := $(out_base)/.clean - -$(default): $(addprefix $(out_base)/,$(addsuffix /,$(tests))) -$(test): $(addprefix $(out_base)/,$(addsuffix /.test,$(tests))) -$(clean): $(addprefix $(out_base)/,$(addsuffix /.clean,$(tests))) - -$(foreach t,$(tests),$(call import,$(src_base)/$t/makefile)) diff --git a/libcutl/tests/compiler/sloc-counter/driver.cxx b/libcutl/tests/compiler/sloc-counter/driver.cxx deleted file mode 100644 index 504fbb7..0000000 --- a/libcutl/tests/compiler/sloc-counter/driver.cxx +++ /dev/null @@ -1,36 +0,0 @@ -// file : tests/compiler/sloc-counter/driver.cxx -// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC -// license : MIT; see accompanying LICENSE file - -#include <fstream> -#include <iostream> - -#include <cutl/compiler/code-stream.hxx> -#include <cutl/compiler/sloc-counter.hxx> - -using namespace std; -using namespace cutl::compiler; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " <file>" << endl; - return 1; - } - - ostream_filter<sloc_counter, char> filt (cout); - - ifstream ifs(argv[1]); - - for (istream::int_type c (ifs.get ()); - c != istream::traits_type::eof (); - c = ifs.get ()) - { - cout.put (istream::traits_type::to_char_type (c)); - } - - cout << endl - << filt.stream ().count () << endl; -} diff --git a/libcutl/tests/compiler/sloc-counter/makefile b/libcutl/tests/compiler/sloc-counter/makefile deleted file mode 100644 index 74c9a4a..0000000 --- a/libcutl/tests/compiler/sloc-counter/makefile +++ /dev/null @@ -1,70 +0,0 @@ -# file : tests/compiler/sloc-counter/makefile -# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC -# license : MIT; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../build/bootstrap.make - -cxx_tun := driver.cxx - -# -# -cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o)) -cxx_od := $(cxx_obj:.o=.o.d) - -cutl.l := $(out_root)/cutl/cutl.l -cutl.l.cpp-options := $(out_root)/cutl/cutl.l.cpp-options - -driver := $(out_base)/driver -test := $(out_base)/.test -clean := $(out_base)/.clean - -# Build. -# -$(driver): $(cxx_obj) $(cutl.l) -$(cxx_obj) $(cxx_od): $(cutl.l.cpp-options) - - -$(call include-dep,$(cxx_od)) - - -# Alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) $(src_base)/test.cxx $(src_base)/test.std - $(call message,test $$1,$$1 $(src_base)/test.cxx | diff -u $(src_base)/test.std -,$(driver)) - - -# Clean. -# -$(clean): \ - $(driver).o.clean \ - $(addsuffix .cxx.clean,$(cxx_obj)) \ - $(addsuffix .cxx.clean,$(cxx_od)) - - -# Generated .gitignore. -# -ifeq ($(out_base),$(src_base)) -$(driver): | $(out_base)/.gitignore - -$(out_base)/.gitignore: files := driver -$(clean): $(out_base)/.gitignore.clean - -$(call include,$(bld_root)/git/gitignore.make) -endif - - -# How to. -# -$(call include,$(bld_root)/cxx/o-e.make) -$(call include,$(bld_root)/cxx/cxx-o.make) -$(call include,$(bld_root)/cxx/cxx-d.make) - -# Dependencies. -# -$(call import,$(src_root)/cutl/makefile) diff --git a/libcutl/tests/compiler/sloc-counter/test.cxx b/libcutl/tests/compiler/sloc-counter/test.cxx deleted file mode 100644 index ff0f5b2..0000000 --- a/libcutl/tests/compiler/sloc-counter/test.cxx +++ /dev/null @@ -1,34 +0,0 @@ -// C++ comment - // C++ comment - -/* C comment */ - -/* Multiline - C - Comment - - -*/ - -#include <iostream> - -char str[] = "multi\ -line\ -string\ -literal"; - -using namespace std; - - -int main( - int argc /*count*/, - char* argv[] /*array*/) -{ - /* comment start */ int x = 0; - char* s = - /* comment start */"foo"; - int y = 2 - /* tricky stuff *// - 2; - cerr << "Hello, \"world!" << '\'' << endl; -} diff --git a/libcutl/tests/compiler/sloc-counter/test.std b/libcutl/tests/compiler/sloc-counter/test.std deleted file mode 100644 index 00b9c31..0000000 --- a/libcutl/tests/compiler/sloc-counter/test.std +++ /dev/null @@ -1,36 +0,0 @@ -// C++ comment - // C++ comment - -/* C comment */ - -/* Multiline - C - Comment - - -*/ - -#include <iostream> - -char str[] = "multi\ -line\ -string\ -literal"; - -using namespace std; - - -int main( - int argc /*count*/, - char* argv[] /*array*/) -{ - /* comment start */ int x = 0; - char* s = - /* comment start */"foo"; - int y = 2 - /* tricky stuff *// - 2; - cerr << "Hello, \"world!" << '\'' << endl; -} - -18 diff --git a/libcutl/tests/compiler/traversal/driver.cxx b/libcutl/tests/compiler/traversal/driver.cxx deleted file mode 100644 index b1fea74..0000000 --- a/libcutl/tests/compiler/traversal/driver.cxx +++ /dev/null @@ -1,139 +0,0 @@ -// file : tests/compiler/traversal/driver.cxx -// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC -// license : MIT; see accompanying LICENSE file - -#include <vector> -#include <iostream> - -#include <cutl/shared-ptr.hxx> - -#include <cutl/compiler/type-info.hxx> -#include <cutl/compiler/traversal.hxx> - -using namespace std; -using namespace cutl; - -// Data types. -// -struct base -{ - virtual ~base () {} -}; - -struct derived1: base {}; -struct derived2: base {}; - -typedef vector<shared_ptr<base> > objects; - -struct init -{ - init () - { - using compiler::type_info; - - { - type_info ti (typeid (base)); - insert (ti); - } - - { - type_info ti (typeid (derived1)); - ti.add_base (typeid (base)); - insert (ti); - } - - { - type_info ti (typeid (derived2)); - ti.add_base (typeid (base)); - insert (ti); - } - } -} init_; - -// Traversers. -// -template <typename X> -struct traverser: compiler::traverser_impl<X, base>, - virtual compiler::dispatcher<base> -{ - void - add_traverser (compiler::traverser_map<base>& m) - { - compiler::dispatcher<base>::traverser (m); - } -}; - -typedef traverser<base> base_trav; -typedef traverser<derived1> derived1_trav; -typedef traverser<derived2> derived2_trav; - -struct base_impl: base_trav -{ - virtual void - traverse (type&) - { - cout << "base_impl: base" << endl; - } -}; - -struct derived1_impl: derived1_trav -{ - virtual void - traverse (type&) - { - cout << "derived1_impl: derived1" << endl; - } -}; - -struct combined_impl: derived1_trav, derived2_trav -{ - virtual void - traverse (derived1&) - { - cout << "combined_impl: derived1" << endl; - } - - virtual void - traverse (derived2&) - { - cout << "combined_impl: derived2" << endl; - } -}; - -int -main () -{ - objects o; - o.push_back (shared_ptr<base> (new (shared) base)); - o.push_back (shared_ptr<base> (new (shared) derived1)); - o.push_back (shared_ptr<base> (new (shared) derived2)); - - base_impl base; - derived1_impl derived1; - combined_impl combined; - - for (objects::iterator i (o.begin ()); i != o.end (); ++i) - base.dispatch (**i); - - cout << endl; - - for (objects::iterator i (o.begin ()); i != o.end (); ++i) - derived1.dispatch (**i); - - cout << endl; - - for (objects::iterator i (o.begin ()); i != o.end (); ++i) - combined.dispatch (**i); - - cout << endl; - - base.add_traverser (derived1); - for (objects::iterator i (o.begin ()); i != o.end (); ++i) - base.dispatch (**i); - - cout << endl; - - derived1.add_traverser (combined); - for (objects::iterator i (o.begin ()); i != o.end (); ++i) - derived1.dispatch (**i); -} diff --git a/libcutl/tests/compiler/traversal/makefile b/libcutl/tests/compiler/traversal/makefile deleted file mode 100644 index f1c0fcf..0000000 --- a/libcutl/tests/compiler/traversal/makefile +++ /dev/null @@ -1,70 +0,0 @@ -# file : tests/compiler/traversal/makefile -# copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC -# license : MIT; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../build/bootstrap.make - -cxx_tun := driver.cxx - -# -# -cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o)) -cxx_od := $(cxx_obj:.o=.o.d) - -cutl.l := $(out_root)/cutl/cutl.l -cutl.l.cpp-options := $(out_root)/cutl/cutl.l.cpp-options - -driver := $(out_base)/driver -test := $(out_base)/.test -clean := $(out_base)/.clean - -# Build. -# -$(driver): $(cxx_obj) $(cutl.l) -$(cxx_obj) $(cxx_od): $(cutl.l.cpp-options) - - -$(call include-dep,$(cxx_od)) - - -# Alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) $(src_base)/output.std - $(call message,test $$1,$$1 | diff -u $(src_base)/output.std -,$(driver)) - - -# Clean. -# -$(clean): \ - $(driver).o.clean \ - $(addsuffix .cxx.clean,$(cxx_obj)) \ - $(addsuffix .cxx.clean,$(cxx_od)) - - -# Generated .gitignore. -# -ifeq ($(out_base),$(src_base)) -$(driver): | $(out_base)/.gitignore - -$(out_base)/.gitignore: files := driver -$(clean): $(out_base)/.gitignore.clean - -$(call include,$(bld_root)/git/gitignore.make) -endif - - -# How to. -# -$(call include,$(bld_root)/cxx/o-e.make) -$(call include,$(bld_root)/cxx/cxx-o.make) -$(call include,$(bld_root)/cxx/cxx-d.make) - -# Dependencies. -# -$(call import,$(src_root)/cutl/makefile) diff --git a/libcutl/tests/compiler/traversal/output.std b/libcutl/tests/compiler/traversal/output.std deleted file mode 100644 index 095739c..0000000 --- a/libcutl/tests/compiler/traversal/output.std +++ /dev/null @@ -1,16 +0,0 @@ -base_impl: base -base_impl: base -base_impl: base - -derived1_impl: derived1 - -combined_impl: derived1 -combined_impl: derived2 - -base_impl: base -derived1_impl: derived1 -base_impl: base - -derived1_impl: derived1 -combined_impl: derived1 -combined_impl: derived2 |