Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Unified Diff: mojom/mojom_parser/mojom/user_defined_types_test.go

Issue 1805743003: Mojom frontend: Compute, validate and populate struct field version info (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Rename ComputeDataForGenerators to ComputeFinalData Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojom/mojom_parser/mojom/user_defined_types.go ('k') | mojom/mojom_parser/parser/computed_data_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojom/mojom_parser/mojom/user_defined_types_test.go
diff --git a/mojom/mojom_parser/mojom/user_defined_types_test.go b/mojom/mojom_parser/mojom/user_defined_types_test.go
index 4b10494b2cb08d91af4c2849aaeef23df18461dd..1a365a1ba28af3a90c69bbea615d4c8d03e9f490 100644
--- a/mojom/mojom_parser/mojom/user_defined_types_test.go
+++ b/mojom/mojom_parser/mojom/user_defined_types_test.go
@@ -134,6 +134,45 @@ func TestStructFieldValidateDefaultValue(t *testing.T) {
}
}
+func TestStructFieldMinVersionAttribute(t *testing.T) {
+ dummyLiteralValue := MakeBoolLiteralValue(false, &lexer.Token{})
+ cases := []struct {
+ includeAttributes bool
+ includeMinVersionAttribute bool
+ attributeValue LiteralValue
+ expectedValue uint32
+ expectedFound bool
+ expectedOk bool
+ }{
+ {false, false, dummyLiteralValue, 0, false, false},
+ {true, false, dummyLiteralValue, 0, false, false},
+ {true, true, MakeUint32LiteralValue(123, &lexer.Token{}), 123, true, true},
+ {true, true, MakeFloatLiteralValue(1.1, &lexer.Token{}), 0, true, false},
+ {true, true, MakeInt64LiteralValue(1234567890123, &lexer.Token{}), 1912276171, true, false},
+ }
+ for i, c := range cases {
+ var attributes *Attributes
+ if c.includeAttributes {
+ attributes = NewAttributes(lexer.Token{})
+ attributes.List = append(attributes.List,
+ NewMojomAttribute("dummy", nil, dummyLiteralValue))
+ if c.includeMinVersionAttribute {
+ attributes.List = append(attributes.List,
+ NewMojomAttribute("MinVersion", nil, c.attributeValue))
+ }
+ attributes.List = append(attributes.List,
+ NewMojomAttribute("dummy2", nil, dummyLiteralValue))
+ }
+ structField := NewStructField(
+ DeclTestDataA(fmt.Sprintf("field%d", i), attributes),
+ SimpleTypeInt8, nil)
+ value, _, found, ok := structField.minVersionAttribute()
+ if found != c.expectedFound || ok != c.expectedOk || value != c.expectedValue {
+ t.Errorf("case %d: found=%v, ok=%v, value=%v", i, found, ok, value)
+ }
+ }
+}
+
func TestInterfaceComputeMethodOridnals(t *testing.T) {
myInterface := NewTestInterface("MyInterface")
myInterface.InitAsScope(NewTestFileScope("test.scope"))
« no previous file with comments | « mojom/mojom_parser/mojom/user_defined_types.go ('k') | mojom/mojom_parser/parser/computed_data_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698