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

Side by Side Diff: pkg/analyzer/test/src/summary/flat_buffers_test.dart

Issue 1571593002: Support for Int64 and fix for the root reference. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library test.src.summary.flat_buffers_test; 5 library test.src.summary.flat_buffers_test;
6 6
7 import 'package:analyzer/src/summary/flat_buffers.dart'; 7 import 'package:analyzer/src/summary/flat_buffers.dart';
8 import 'package:unittest/unittest.dart'; 8 import 'package:unittest/unittest.dart';
9 9
10 import '../../reflective_tests.dart'; 10 import '../../reflective_tests.dart';
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 byteList = builder.finish(offset); 79 byteList = builder.finish(offset);
80 } 80 }
81 // read and verify 81 // read and verify
82 BufferPointer object = new BufferPointer.fromBytes(byteList).derefObject(); 82 BufferPointer object = new BufferPointer.fromBytes(byteList).derefObject();
83 // was not written, so uses the new default value 83 // was not written, so uses the new default value
84 expect(const Int32Reader().vTableGet(object, 0, 15), 15); 84 expect(const Int32Reader().vTableGet(object, 0, 15), 15);
85 // has the written value 85 // has the written value
86 expect(const Int32Reader().vTableGet(object, 1, 15), 20); 86 expect(const Int32Reader().vTableGet(object, 1, 15), 20);
87 } 87 }
88 88
89 void test_table_int64() {
90 List<int> byteList;
91 {
92 Builder builder = new Builder(initialSize: 0);
93 builder.startTable();
94 builder.addInt8(0, 10);
95 builder.addInt64(1, 20);
96 builder.addInt8(2, 30);
97 builder.addInt8(3, 40);
98 builder.addInt8(4, 50);
99 Offset offset = builder.endTable();
100 byteList = builder.finish(offset);
101 }
102 // read and verify
103 BufferPointer object = new BufferPointer.fromBytes(byteList).derefObject();
104 expect(const Int8Reader().vTableGet(object, 0), 10);
105 expect(const Int64Reader().vTableGet(object, 1), 20);
106 expect(const Int8Reader().vTableGet(object, 2), 30);
107 expect(const Int8Reader().vTableGet(object, 3), 40);
108 expect(const Int8Reader().vTableGet(object, 4), 50);
109 }
110
89 void test_table_types() { 111 void test_table_types() {
90 List<int> byteList; 112 List<int> byteList;
91 { 113 {
92 Builder builder = new Builder(initialSize: 0); 114 Builder builder = new Builder(initialSize: 0);
93 Offset<String> stringOffset = builder.writeString('12345'); 115 Offset<String> stringOffset = builder.writeString('12345');
94 builder.startTable(); 116 builder.startTable();
95 builder.addInt8(0, 10); 117 builder.addInt8(0, 10);
96 builder.addInt32(1, 20); 118 builder.addInt32(1, 20);
97 builder.addOffset(2, stringOffset); 119 builder.addOffset(2, stringOffset);
98 builder.addInt32(3, 40); 120 builder.addInt32(3, 40);
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 228
207 int get x => const Int32Reader().vTableGet(bp, 0, 0); 229 int get x => const Int32Reader().vTableGet(bp, 0, 0);
208 230
209 int get y => const Int32Reader().vTableGet(bp, 1, 0); 231 int get y => const Int32Reader().vTableGet(bp, 1, 0);
210 232
211 @override 233 @override
212 TestPointReader createReader(BufferPointer object) { 234 TestPointReader createReader(BufferPointer object) {
213 return new TestPointReader._(object); 235 return new TestPointReader._(object);
214 } 236 }
215 } 237 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698