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

Unified Diff: mojom/mojom_parser/parser/resolution_test.go

Issue 1515343002: New Mojom Parser: Validate the use of '&' and '?' (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Revert accidental commit. Created 5 years 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/types.go ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojom/mojom_parser/parser/resolution_test.go
diff --git a/mojom/mojom_parser/parser/resolution_test.go b/mojom/mojom_parser/parser/resolution_test.go
index 9e3857f41c3359a9a197c931f990b0c23d4ded4e..80f4d7bff53b95dadb1909673b9373c1abe61531 100644
--- a/mojom/mojom_parser/parser/resolution_test.go
+++ b/mojom/mojom_parser/parser/resolution_test.go
@@ -827,6 +827,66 @@ func TestSingleFileTypeValidationErrors(t *testing.T) {
}
////////////////////////////////////////////////////////////
+ // Group 3: Invalid use of interface request.
+ ////////////////////////////////////////////////////////////
+
+ ////////////////////////////////////////////////////////////
+ // Test Case: Make an interface request out of a struct
+ ////////////////////////////////////////////////////////////
+ {
+ contents := `
+ struct Foo{
+ };
+
+ struct Bar{
+ Foo& x;
+ };
+ `
+ test.addTestCase(contents, []string{
+ "Invalid interface request specification",
+ "Foo&. Foo is not an interface type"})
+ }
+
+ ////////////////////////////////////////////////////////////
+ // Test Case: Make a nullable interface request out of a struct
+ ////////////////////////////////////////////////////////////
+ {
+ contents := `
+ struct Foo{
+ };
+
+ struct Bar{
+ Foo&? x;
+ };
+ `
+ test.addTestCase(contents, []string{
+ "Invalid interface request specification",
+ "Foo&?. Foo is not an interface type"})
+ }
+
+ ////////////////////////////////////////////////////////////
+ // Group 4: Invalid use of nullable
+ ////////////////////////////////////////////////////////////
+
+ ////////////////////////////////////////////////////////////
+ // Test Case: Make nullable enum.
+ ////////////////////////////////////////////////////////////
+ {
+ contents := `
+ enum Hats {
+ COWBOY,
+ TOP
+ };
+
+ struct Bar{
+ Hats? my_hat;
+ };
+ `
+ test.addTestCase(contents, []string{
+ "The type Hats? is invalid because Hats is an enum type and these may not be made nullable."})
+ }
+
+ ////////////////////////////////////////////////////////////
// Execute all of the test cases.
////////////////////////////////////////////////////////////
for i, c := range test.cases {
« no previous file with comments | « mojom/mojom_parser/mojom/types.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698