summaryrefslogtreecommitdiff
path: root/tests/scripts/variables
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2009-05-26 01:31:40 +0000
committerPaul Smith <psmith@gnu.org>2009-05-26 01:31:40 +0000
commit5b4d419476e9fbda8ea26017f6ec15956d103ed9 (patch)
tree534eac34c276b58bbbfa1d104820843af666d1a1 /tests/scripts/variables
parent7b16a8e3ca8e9866df29df868a4cb1b6771d5f48 (diff)
downloadgunmake-5b4d419476e9fbda8ea26017f6ec15956d103ed9.tar.gz
Add 'private' variable modifier, feature submitted by Ramon Garcia.
Rework the parser for variables to allow multiple modifiers and also allow for variables and targets with modifier names, like "export" and "private".
Diffstat (limited to 'tests/scripts/variables')
-rw-r--r--tests/scripts/variables/private78
1 files changed, 78 insertions, 0 deletions
diff --git a/tests/scripts/variables/private b/tests/scripts/variables/private
new file mode 100644
index 0000000..b4baf5f
--- /dev/null
+++ b/tests/scripts/variables/private
@@ -0,0 +1,78 @@
+# -*-perl-*-
+
+$description = "Test 'private' variables.";
+
+$details = "";
+
+# 1: Simple verification that private variables are not inherited
+&run_make_test('
+a:
+F = g
+a: F = a
+b: private F = b
+
+a b c: ; @echo $@: F=$(F)
+a: b
+b: c
+',
+ '', "c: F=a\nb: F=b\na: F=a\n");
+
+# 2: Again, but this time we start with "b" so "a"'s variable is not in scope
+&run_make_test(undef, 'b', "c: F=g\nb: F=b\n");
+
+# 3: Verification with pattern-specific variables
+&run_make_test('
+t.a:
+
+F1 = g
+F2 = g
+%.a: private F1 = a
+%.a: F2 = a
+
+t.a t.b: ; @echo $@: F1=$(F1) / F2=$(F2)
+t.a: t.b
+',
+ '', "t.b: F1=g / F2=a\nt.a: F1=a / F2=a\n");
+
+# 4: Test private global variables
+&run_make_test('
+a:
+private F = g
+G := $(F)
+a:
+b: F = b
+
+a b: ; @echo $@: F=$(F) / G=$(G)
+a: b
+',
+ '', "b: F=b / G=g\na: F= / G=g\n");
+
+# 5: Multiple conditions on the same variable. Test export.
+delete $ENV{'_X'};
+&run_make_test('
+_X = x
+a: export override private _X = a
+a: ; @echo _X=$(_X) / _X=$$_X
+',
+ '', "_X=a / _X=a");
+
+# 6: Test override.
+&run_make_test(undef, '_X=c', "_X=a / _X=a\n");
+
+# 7: Ensure keywords still work as targets
+&run_make_test('
+a: export override private foo bar
+foo bar export override private: ; @echo $@
+',
+ '', "export\noverride\nprivate\nfoo\nbar\n");
+
+# 8: Ensure keywords still work as variables
+&run_make_test('
+private = g
+a: private = a
+a: b
+a b: ; @echo $@=$(private)
+',
+ '', "b=a\na=a\n");
+
+1;