diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2010-06-02 17:22:12 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2010-06-02 17:22:12 +0200 |
commit | ed60746355044dd39acd82b8f42c4d9886914567 (patch) | |
tree | a958825cb9bca8960eafb41c373d91e22ca9e4ed /tests/specifier | |
parent | 62166bfe7031522bd851eb5d7047a19182e24a45 (diff) |
Implement generation of specifier functions (--generate-specifier)
These functions determine whether the option was specified on the command
line. New test: specifier.
Diffstat (limited to 'tests/specifier')
-rw-r--r-- | tests/specifier/driver.cxx | 30 | ||||
-rw-r--r-- | tests/specifier/makefile | 73 | ||||
-rw-r--r-- | tests/specifier/test.cli | 13 |
3 files changed, 116 insertions, 0 deletions
diff --git a/tests/specifier/driver.cxx b/tests/specifier/driver.cxx new file mode 100644 index 0000000..9f9005a --- /dev/null +++ b/tests/specifier/driver.cxx @@ -0,0 +1,30 @@ +// file : tests/specifier/driver.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC +// license : MIT; see accompanying LICENSE file + +// Test specifier functions. +// + +#include <string> +#include <cassert> + +#include "test.hxx" + +using namespace std; + +int +main (int argc, char* argv[]) +{ + options o (argc, argv); + + assert (o.a ()); + assert (o.b () == 1 && !o.b_specified ()); + assert (o.c () == "foo" && o.c_specified ()); + + o.b_specified (true); + o.c_specified (false); + + assert (o.b_specified ()); + assert (!o.c_specified ()); +} diff --git a/tests/specifier/makefile b/tests/specifier/makefile new file mode 100644 index 0000000..d2f67a3 --- /dev/null +++ b/tests/specifier/makefile @@ -0,0 +1,73 @@ +# file : tests/specifier/makefile +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC +# license : MIT; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../../build/bootstrap.make + +cxx_tun := driver.cxx +cli_tun := test.cli + +# +# +cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o) $(cli_tun:.cli=.o)) +cxx_od := $(cxx_obj:.o=.o.d) + +driver := $(out_base)/driver +test := $(out_base)/.test +clean := $(out_base)/.clean + +# Build. +# +$(driver): $(cxx_obj) +$(cxx_obj) $(cxx_od): cpp_options := -I$(out_base) + +genf := $(cli_tun:.cli=.hxx) $(cli_tun:.cli=.ixx) $(cli_tun:.cli=.cxx) +gen := $(addprefix $(out_base)/,$(genf)) + +$(gen): $(out_root)/cli/cli +$(gen): cli := $(out_root)/cli/cli +$(gen): cli_options := --generate-specifier --generate-modifier + +$(call include-dep,$(cxx_od),$(cxx_obj),$(gen)) + +# Alias for default target. +# +$(out_base)/: $(driver) + +# Test. +# +$(test): driver := $(driver) +$(test): $(driver) + $(call message,test $$1,$$1 -a -c foo,$(driver)) + +# Clean. +# +$(clean): \ + $(driver).o.clean \ + $(addsuffix .cxx.clean,$(cxx_obj)) \ + $(addsuffix .cxx.clean,$(cxx_od)) \ + $(addprefix $(out_base)/,$(cli_tun:.cli=.cxx.cli.clean)) + +# Generated .gitignore. +# +ifeq ($(out_base),$(src_base)) +$(driver): | $(out_base)/.gitignore + +$(out_base)/.gitignore: files := driver $(genf) +$(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) +$(call include,$(scf_root)/cli/cli-cxx.make) + +# Dependencies. +# +$(call import,$(src_root)/cli/makefile) + diff --git a/tests/specifier/test.cli b/tests/specifier/test.cli new file mode 100644 index 0000000..e9c9ad0 --- /dev/null +++ b/tests/specifier/test.cli @@ -0,0 +1,13 @@ +// file : tests/specifier/test.cli +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC +// license : MIT; see accompanying LICENSE file + +include <string>; + +class options +{ + bool -a; + int -b = 1; + std::string -c; +}; |