From 8286ac511144e4f17d34eac9affb97e50646344a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Wed, 23 Jul 2014 15:25:44 +0200 Subject: Imported Upstream version 4.0.0 --- libcutl/tests/compiler/cxx-indenter/driver.cxx | 168 +++++++++++++++++++++++++ libcutl/tests/compiler/cxx-indenter/makefile | 70 +++++++++++ libcutl/tests/compiler/cxx-indenter/output.std | 103 +++++++++++++++ 3 files changed, 341 insertions(+) create mode 100644 libcutl/tests/compiler/cxx-indenter/driver.cxx create mode 100644 libcutl/tests/compiler/cxx-indenter/makefile create mode 100644 libcutl/tests/compiler/cxx-indenter/output.std (limited to 'libcutl/tests/compiler/cxx-indenter') diff --git a/libcutl/tests/compiler/cxx-indenter/driver.cxx b/libcutl/tests/compiler/cxx-indenter/driver.cxx new file mode 100644 index 0000000..665c6ab --- /dev/null +++ b/libcutl/tests/compiler/cxx-indenter/driver.cxx @@ -0,0 +1,168 @@ +// file : tests/compiler/cxx-indenter/driver.cxx +// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +// license : MIT; see accompanying LICENSE file + +#include +#include + +#include +#include + +using namespace std; +using namespace cutl::compiler; + +int +main () +{ + //std::wostream& os (wcout); + //ostream_filter filt (os); + + std::ostream& os (cout); + ostream_filter 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 " << 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 new file mode 100644 index 0000000..da5dbe0 --- /dev/null +++ b/libcutl/tests/compiler/cxx-indenter/makefile @@ -0,0 +1,70 @@ +# 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 new file mode 100644 index 0000000..79e74f4 --- /dev/null +++ b/libcutl/tests/compiler/cxx-indenter/output.std @@ -0,0 +1,103 @@ +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 +#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 + } + }; +} + -- cgit v1.2.3