summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-06-02 17:22:12 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-06-02 17:22:12 +0200
commited60746355044dd39acd82b8f42c4d9886914567 (patch)
treea958825cb9bca8960eafb41c373d91e22ca9e4ed /tests
parent62166bfe7031522bd851eb5d7047a19182e24a45 (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')
-rw-r--r--tests/makefile2
-rw-r--r--tests/specifier/driver.cxx30
-rw-r--r--tests/specifier/makefile73
-rw-r--r--tests/specifier/test.cli13
4 files changed, 117 insertions, 1 deletions
diff --git a/tests/makefile b/tests/makefile
index 109c48d..0d96d76 100644
--- a/tests/makefile
+++ b/tests/makefile
@@ -5,7 +5,7 @@
include $(dir $(lastword $(MAKEFILE_LIST)))../build/bootstrap.make
-tests := ctor erase file lexer parser
+tests := ctor erase file lexer parser specifier
default := $(out_base)/
test := $(out_base)/.test
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;
+};