aboutsummaryrefslogtreecommitdiffstats
path: root/unpack_test.go
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2015-10-30 15:53:55 -0700
committerColin Cross <ccross@android.com>2015-11-02 13:59:12 -0800
commit80117687294aaebcdc1df11a456cd1655e58ab8d (patch)
tree31c3add8cd2d3de933a36e8e2b41e70e6a7b9d72 /unpack_test.go
parentecca05efb23c43093afeb97a922cdfdb7c6248f6 (diff)
downloadandroid_build_blueprint-80117687294aaebcdc1df11a456cd1655e58ab8d.tar.gz
android_build_blueprint-80117687294aaebcdc1df11a456cd1655e58ab8d.tar.bz2
android_build_blueprint-80117687294aaebcdc1df11a456cd1655e58ab8d.zip
Add property support for pointers to bools and strings
The only append semantics for bool that result in a no-op when the zero value is appended is to OR the two values together, but that is rarely the desired semantics. Add support for *bool and *string as property types, where appending a nil pointer is a no-op. For *bool, appending a non-nil pointer replaces the destination with the value. For *string, appending a non-nil pointer appends the value. This also provides a more reliable replacement for ModuleContext.ContainsProperty, as the build logic can tell that the property was set, even if it was set by a mutator and not by the blueprints file, by testing against nil. []string already provides these semantics for lists. Setting a *bool or *string property from a blueprints file is the same syntax as setting a bool or a string property.
Diffstat (limited to 'unpack_test.go')
-rw-r--r--unpack_test.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/unpack_test.go b/unpack_test.go
index 0b31efc..77a57ec 100644
--- a/unpack_test.go
+++ b/unpack_test.go
@@ -33,6 +33,24 @@ var validUnpackTestCases = []struct {
{`
m {
name: "abc",
+ blank: "",
+ }
+ `,
+ struct {
+ Name *string
+ Blank *string
+ Unset *string
+ }{
+ Name: proptools.StringPtr("abc"),
+ Blank: proptools.StringPtr(""),
+ Unset: nil,
+ },
+ nil,
+ },
+
+ {`
+ m {
+ name: "abc",
}
`,
struct {
@@ -58,6 +76,24 @@ var validUnpackTestCases = []struct {
{`
m {
+ isGood: true,
+ isBad: false,
+ }
+ `,
+ struct {
+ IsGood *bool
+ IsBad *bool
+ IsUgly *bool
+ }{
+ IsGood: proptools.BoolPtr(true),
+ IsBad: proptools.BoolPtr(false),
+ IsUgly: nil,
+ },
+ nil,
+ },
+
+ {`
+ m {
stuff: ["asdf", "jkl;", "qwert",
"uiop", "bnm,"],
empty: []