From 57abb0703ec640fdcd0b0ac165f742bbc34df533 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 14 Jun 2017 13:06:38 +0200 Subject: Next installment in C++ modules saga: module search, re-export support --- tests/cc/modules/testscript | 154 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 139 insertions(+), 15 deletions(-) (limited to 'tests/cc') diff --git a/tests/cc/modules/testscript b/tests/cc/modules/testscript index 71ae34d..38a3fde 100644 --- a/tests/cc/modules/testscript +++ b/tests/cc/modules/testscript @@ -41,22 +41,22 @@ if $modules # Common source files that are symlinked (@@ TODO: ln builtin) in the # test directories if used. # -+cat <=test.mxx ++cat <=core.mxx #if __cpp_modules >= 201704 export #endif -module foo.test; +module foo.core; export int f (int); EOI -+cat <=test.cxx -module foo.test; ++cat <=core.cxx +module foo.core; int f (int i) {return i - 1;} EOI +cat <=driver.cxx -import foo.test; +import foo.core; int main (int argc, char*[]) {return f (argc);} EOI @@ -65,13 +65,13 @@ EOI : Test combined interface/implementation unit specified as bmi{}. : if ($cxx.id != "gcc") -cp ../test.mxx ./ && cat >+test.mxx <+core.mxx <+test.mxx <+core.mxx <=core.mxx + #if __cpp_modules >= 201704 + export + #endif + module bar.core; + EOI + + : separator + : + : Test separator equivalence. + : + cp ../../core.mxx foo-core.mxx; + cp ../core.mxx ../../core.cxx ../../driver.cxx ./; + $* test clean <'exe{test}: cxx{driver core} mxx{core foo-core}' + + : case + : + : Test case-insensitivity and case-change as a separator. + : + cp ../../core.mxx FooCore.mxx; + cp ../core.mxx ../../core.cxx ../../driver.cxx ./; + $* test clean <'exe{test}: cxx{driver core} mxx{core FooCore}' + + : dir + : + : Test subdirectory. + : + mkdir foo; + cp ../../core.mxx foo/core.mxx; + cp ../core.mxx ../../core.cxx ../../driver.cxx ./; + $* test clean <'exe{test}: cxx{driver core} mxx{core} foo/mxx{core}' +} + +: unresolved +: +cp ../driver.cxx ./; +$* test &*.d <'exe{test}: cxx{driver}' 2>>EOE != 0 + error: unresolved import for module foo.core + EOE + +: misguessed +: +cp ../core.mxx ./; +cat <'import bar.core;' >=driver.cxx; +$* test &*.d <'exe{test}: cxx{driver} mxx{core}' 2>>EOE != 0 + error: failed to correctly guess module name from mxx{core} + info: guessed: bar.core + info: actual: foo.core + info: consider adjusting module interface file names or + info: consider explicitly specifying module name with @@ MOD + EOE + + +: re-export +: +: Test module re-exporting (export import M;) +: +if ($cxx.id.type != "clang") +{ + +cat <=base.mxx + #if __cpp_modules >= 201704 + export + #endif + module foo.base; + export import foo.core; + EOI + + +cat <=extra.mxx + #if __cpp_modules >= 201704 + export + #endif + module foo.extra; + export import foo.base; + EOI + + +cat <=foo.mxx + #if __cpp_modules >= 201704 + export + #endif + module foo; + export + { + import foo.core; + import foo.base; + import foo.extra; + } + EOI + + : basic + : + cp ../base.mxx ../../core.mxx ../../core.cxx ./; + cat <=driver.cxx; + import foo.base; + int main (int argc, char*[]) {return f (argc);} + EOI + $* test clean <'exe{test}: cxx{driver core} {mxx}{core base}' + + : recursive + : + cp ../base.mxx ../extra.mxx ../../core.mxx ../../core.cxx ./; + cat <=driver.cxx; + import foo.extra; + int main (int argc, char*[]) {return f (argc);} + EOI + $* test clean <'exe{test}: cxx{driver core} {mxx}{core base extra}' + + : duplicate + : + cp ../base.mxx ../extra.mxx ../foo.mxx ../../core.mxx ../../core.cxx ./; + cat <=driver.cxx; + import foo; + int main (int argc, char*[]) {return f (argc);} + EOI + $* test clean <'exe{test}: cxx{driver core} {mxx}{core base extra foo}' +} + } -- cgit v1.1