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

Side by Side Diff: mojo/public/tools/bindings/pylib/mojom/generate/pack_tests.py

Issue 1833593002: Mojom compiler: Port pack tests to the frontend. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Fix spelling of test name. 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 unified diff | Download patch
« no previous file with comments | « no previous file | mojom/mojom_parser/mojom/computed_data.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import sys 5 import sys
6 6
7 import module as mojom 7 import module as mojom
8 import pack 8 import pack
9 import test_support 9 import test_support
10 10
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 mojom.Struct('test_struct').MakeNullableKind(), 94 mojom.Struct('test_struct').MakeNullableKind(),
95 mojom.DCPIPE.MakeNullableKind(), 95 mojom.DCPIPE.MakeNullableKind(),
96 mojom.Array().MakeNullableKind(), 96 mojom.Array().MakeNullableKind(),
97 mojom.DPPIPE.MakeNullableKind(), 97 mojom.DPPIPE.MakeNullableKind(),
98 mojom.Array(length=5).MakeNullableKind(), 98 mojom.Array(length=5).MakeNullableKind(),
99 mojom.MSGPIPE.MakeNullableKind(), 99 mojom.MSGPIPE.MakeNullableKind(),
100 mojom.Interface('test_inteface').MakeNullableKind(), 100 mojom.Interface('test_inteface').MakeNullableKind(),
101 mojom.SHAREDBUFFER.MakeNullableKind(), 101 mojom.SHAREDBUFFER.MakeNullableKind(),
102 mojom.InterfaceRequest().MakeNullableKind()) 102 mojom.InterfaceRequest().MakeNullableKind())
103 fields = (1, 2, 4, 3, 5, 6, 8, 7, 9, 10, 11) 103 fields = (1, 2, 4, 3, 5, 6, 8, 7, 9, 10, 11)
104 offsets = (0, 8, 12, 16, 24, 32, 36, 40, 48, 52, 56) 104 offsets = (0, 8, 12, 16, 24, 32, 36, 40, 48, 56, 60)
105 return TestSequence(kinds, fields, offsets) 105 return TestSequence(kinds, fields, offsets)
106 106
107 107
108 def TestAllTypes(): 108 def TestAllTypes():
109 return TestSequence( 109 return TestSequence(
110 (mojom.BOOL, mojom.INT8, mojom.STRING, mojom.UINT8, 110 (mojom.BOOL, mojom.INT8, mojom.STRING, mojom.UINT8,
111 mojom.INT16, mojom.DOUBLE, mojom.UINT16, 111 mojom.INT16, mojom.DOUBLE, mojom.UINT16,
112 mojom.INT32, mojom.UINT32, mojom.INT64, 112 mojom.INT32, mojom.UINT32, mojom.INT64,
113 mojom.FLOAT, mojom.STRING, mojom.HANDLE, 113 mojom.FLOAT, mojom.STRING, mojom.HANDLE,
114 mojom.UINT64, mojom.Struct('test'), mojom.Array(), 114 mojom.UINT64, mojom.Struct('test'), mojom.Array(),
115 mojom.STRING.MakeNullableKind()), 115 mojom.STRING.MakeNullableKind()),
116 (1, 2, 4, 5, 7, 3, 6, 8, 9, 10, 11, 13, 12, 14, 15, 16, 17, 18), 116 (1, 2, 4, 5, 7, 3, 6, 8, 9, 10, 11, 13, 12, 14, 15, 16, 17, 18),
117 (0, 1, 2, 4, 6, 8, 16, 24, 28, 32, 40, 44, 48, 56, 64, 72, 80, 88)) 117 (0, 1, 2, 4, 6, 8, 16, 24, 28, 32, 40, 44, 48, 56, 64, 72, 80))
118 118
119 119
120 def TestPaddingPackedOutOfOrderByOrdinal(): 120 def TestPaddingPackedOutOfOrderByOrdinal():
121 errors = 0 121 errors = 0
122 struct = mojom.Struct('test') 122 struct = mojom.Struct('test')
123 struct.AddField('testfield1', mojom.INT8) 123 struct.AddField('testfield1', mojom.INT8)
124 struct.AddField('testfield3', mojom.UINT8, 3) 124 struct.AddField('testfield3', mojom.UINT8, 3)
125 struct.AddField('testfield2', mojom.INT32, 2) 125 struct.AddField('testfield2', mojom.INT32, 2)
126 ps = pack.PackedStruct(struct) 126 ps = pack.PackedStruct(struct)
127 errors += EXPECT_EQ(3, len(ps.packed_fields)) 127 errors += EXPECT_EQ(3, len(ps.packed_fields))
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 errors += RunTest(TestNullableTypes) 184 errors += RunTest(TestNullableTypes)
185 errors += RunTest(TestAllTypes) 185 errors += RunTest(TestAllTypes)
186 errors += RunTest(TestPaddingPackedOutOfOrderByOrdinal) 186 errors += RunTest(TestPaddingPackedOutOfOrderByOrdinal)
187 errors += RunTest(TestBools) 187 errors += RunTest(TestBools)
188 188
189 return errors 189 return errors
190 190
191 191
192 if __name__ == '__main__': 192 if __name__ == '__main__':
193 sys.exit(Main(sys.argv[1:])) 193 sys.exit(Main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | mojom/mojom_parser/mojom/computed_data.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698