@@ -75,6 +75,59 @@ unset B[flag]
self.assertEqual(d.getVarFlag("A","flag"), None)
self.assertEqual(d.getVar("B"), "2")
+ defaulttest = """
+A = "set value"
+A ??= "default value"
+
+A[flag_set_vs_question] = "set flag"
+A[flag_set_vs_question] ?= "question flag"
+
+A[flag_set_vs_default] = "set flag"
+A[flag_set_vs_default] ??= "default flag"
+
+A[flag_question] ?= "question flag"
+
+A[flag_default] ??= "default flag"
+
+A[flag_question_vs_default] ?= "question flag"
+A[flag_question_vs_default] ??= "default flag"
+
+A[flag_default_vs_question] ??= "default flag"
+A[flag_default_vs_question] ?= "question flag"
+
+A[flag_set_question_default] = "set flag"
+A[flag_set_question_default] ?= "question flag"
+A[flag_set_question_default] ??= "default flag"
+
+A[flag_set_default_question] = "set flag"
+A[flag_set_default_question] ??= "default flag"
+A[flag_set_default_question] ?= "question flag"
+
+A[flag_set_twice] = "set flag first"
+A[flag_set_twice] = "set flag second"
+
+A[flag_question_twice] ?= "question flag first"
+A[flag_question_twice] ?= "question flag second"
+
+A[flag_default_twice] ??= "default flag first"
+A[flag_default_twice] ??= "default flag second"
+"""
+ def test_parse_defaulttest(self):
+ f = self.parsehelper(self.defaulttest)
+ d = bb.parse.handle(f.name, self.d)['']
+ self.assertEqual(d.getVar("A"), "set value")
+ self.assertEqual(d.getVarFlag("A","flag_set_vs_question"), "set flag")
+ self.assertEqual(d.getVarFlag("A","flag_set_vs_default"), "set flag")
+ self.assertEqual(d.getVarFlag("A","flag_question"), "question flag")
+ self.assertEqual(d.getVarFlag("A","flag_default"), "default flag")
+ self.assertEqual(d.getVarFlag("A","flag_question_vs_default"), "question flag")
+ self.assertEqual(d.getVarFlag("A","flag_default_vs_question"), "question flag")
+ self.assertEqual(d.getVarFlag("A","flag_set_question_default"), "set flag")
+ self.assertEqual(d.getVarFlag("A","flag_set_default_question"), "set flag")
+ self.assertEqual(d.getVarFlag("A","flag_set_twice"), "set flag second")
+ self.assertEqual(d.getVarFlag("A","flag_question_twice"), "question flag first")
+ self.assertEqual(d.getVarFlag("A","flag_default_twice"), "default flag second")
+
exporttest = """
A = "a"
export B = "b"