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

Side by Side Diff: pkg/front_end/test/src/incremental/format_test.dart

Issue 2939653002: FlatBuffers formats for storing unlinked units. (Closed)
Patch Set: Created 3 years, 6 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
(Empty)
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
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.
4
5 import 'dart:typed_data';
6
7 import 'package:front_end/src/base/flat_buffers.dart' as fb;
8 import 'package:front_end/src/incremental/format.dart';
9 import 'package:test/test.dart';
10 import 'package:test_reflective_loader/test_reflective_loader.dart';
11
12 main() {
13 defineReflectiveSuite(() {
14 defineReflectiveTests(FormatTest);
15 });
16 }
17
18 @reflectiveTest
19 class FormatTest {
20 void test_UnlinkedCombinator_hides() {
21 Uint8List bytes;
22 {
23 fb.Builder fbBuilder = new fb.Builder();
24 fb.Offset offset =
25 new UnlinkedCombinatorBuilder(hides: ['a', 'bb', 'ccc'])
26 .finish(fbBuilder);
27 bytes = fbBuilder.finish(offset);
28 }
29
30 var combinator = new UnlinkedCombinator(bytes);
31 expect(combinator.shows, isEmpty);
32 expect(combinator.hides, ['a', 'bb', 'ccc']);
33 }
34
35 void test_UnlinkedCombinator_shows() {
36 Uint8List bytes;
37 {
38 fb.Builder fbBuilder = new fb.Builder();
39 fb.Offset offset =
40 new UnlinkedCombinatorBuilder(shows: ['a', 'bb', 'ccc'])
41 .finish(fbBuilder);
42 bytes = fbBuilder.finish(offset);
43 }
44
45 var combinator = new UnlinkedCombinator(bytes);
46 expect(combinator.shows, ['a', 'bb', 'ccc']);
47 expect(combinator.hides, isEmpty);
48 }
49
50 void test_UnlinkedNamespaceDirective() {
51 Uint8List bytes;
52 {
53 fb.Builder fbBuilder = new fb.Builder();
54 fb.Offset offset = new UnlinkedNamespaceDirectiveBuilder(
55 uri: 'package:foo/foo.dart',
56 combinators: [
57 new UnlinkedCombinatorBuilder(shows: ['aaa']),
58 new UnlinkedCombinatorBuilder(hides: ['bbb', 'ccc'])
59 ]).finish(fbBuilder);
60 bytes = fbBuilder.finish(offset);
61 }
62
63 var directive = new UnlinkedNamespaceDirective(bytes);
64 expect(directive.uri, 'package:foo/foo.dart');
65 expect(directive.combinators, hasLength(2));
66 expect(directive.combinators[0].shows, ['aaa']);
67 expect(directive.combinators[0].hides, isEmpty);
68 expect(directive.combinators[1].shows, isEmpty);
69 expect(directive.combinators[1].hides, ['bbb', 'ccc']);
70 }
71
72 void test_UnlinkedUnit() {
73 Uint8List bytes;
74 {
75 fb.Builder fbBuilder = new fb.Builder();
76 fb.Offset offset = new UnlinkedUnitBuilder(apiSignature: [
77 0,
78 1,
79 2,
80 3,
81 4
82 ], imports: [
83 new UnlinkedNamespaceDirectiveBuilder(uri: 'a.dart')
84 ], exports: [
85 new UnlinkedNamespaceDirectiveBuilder(uri: 'b.dart')
86 ], parts: [
87 new UnlinkedNamespaceDirectiveBuilder(uri: 'p1.dart'),
88 new UnlinkedNamespaceDirectiveBuilder(uri: 'p2.dart'),
89 ]).finish(fbBuilder);
90 bytes = fbBuilder.finish(offset);
91 }
92
93 var directive = new UnlinkedUnit(bytes);
94 expect(directive.apiSignature, [0, 1, 2, 3, 4]);
95
96 expect(directive.imports, hasLength(1));
97 expect(directive.imports[0].uri, 'a.dart');
98
99 expect(directive.exports, hasLength(1));
100 expect(directive.exports[0].uri, 'b.dart');
101
102 expect(directive.parts, hasLength(2));
103 expect(directive.parts[0].uri, 'p1.dart');
104 expect(directive.parts[1].uri, 'p2.dart');
105 }
106 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/incremental/format.dart ('k') | pkg/front_end/test/src/incremental/test_all.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698