| OLD | NEW | 
|---|
| 1 // Copyright (c) 2017, the Dart project authors.  Please see the AUTHORS file | 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 | 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 import 'dart:typed_data'; | 5 import 'dart:typed_data'; | 
| 6 | 6 | 
| 7 import 'package:front_end/src/base/flat_buffers.dart' as fb; |  | 
| 8 import 'package:front_end/src/incremental/format.dart'; | 7 import 'package:front_end/src/incremental/format.dart'; | 
| 9 import 'package:test/test.dart'; | 8 import 'package:test/test.dart'; | 
| 10 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 9 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 
| 11 | 10 | 
| 12 main() { | 11 main() { | 
| 13   defineReflectiveSuite(() { | 12   defineReflectiveSuite(() { | 
| 14     defineReflectiveTests(FormatTest); | 13     defineReflectiveTests(FormatTest); | 
| 15   }); | 14   }); | 
| 16 } | 15 } | 
| 17 | 16 | 
| 18 @reflectiveTest | 17 @reflectiveTest | 
| 19 class FormatTest { | 18 class FormatTest { | 
| 20   void test_UnlinkedCombinator_hides() { | 19   void test_UnlinkedCombinator_isShow_false() { | 
| 21     Uint8List bytes; | 20     Uint8List bytes = new UnlinkedCombinatorBuilder( | 
| 22     { | 21         isShow: false, names: ['aaa', 'bbb', 'ccc']).toBytes(); | 
| 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 | 22 | 
| 30     var combinator = new UnlinkedCombinator(bytes); | 23     var combinator = new UnlinkedCombinator(bytes); | 
| 31     expect(combinator.shows, isEmpty); | 24     expect(combinator.isShow, isFalse); | 
| 32     expect(combinator.hides, ['a', 'bb', 'ccc']); | 25     expect(combinator.names, ['aaa', 'bbb', 'ccc']); | 
| 33   } | 26   } | 
| 34 | 27 | 
| 35   void test_UnlinkedCombinator_shows() { | 28   void test_UnlinkedCombinator_isShow_true() { | 
| 36     Uint8List bytes; | 29     Uint8List bytes = new UnlinkedCombinatorBuilder( | 
| 37     { | 30         isShow: true, names: ['aaa', 'bbb', 'ccc']).toBytes(); | 
| 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 | 31 | 
| 45     var combinator = new UnlinkedCombinator(bytes); | 32     var combinator = new UnlinkedCombinator(bytes); | 
| 46     expect(combinator.shows, ['a', 'bb', 'ccc']); | 33     expect(combinator.isShow, isTrue); | 
| 47     expect(combinator.hides, isEmpty); | 34     expect(combinator.names, ['aaa', 'bbb', 'ccc']); | 
| 48   } | 35   } | 
| 49 | 36 | 
| 50   void test_UnlinkedNamespaceDirective() { | 37   void test_UnlinkedNamespaceDirective() { | 
| 51     Uint8List bytes; | 38     Uint8List bytes = new UnlinkedNamespaceDirectiveBuilder( | 
| 52     { | 39         uri: 'package:foo/foo.dart', | 
| 53       fb.Builder fbBuilder = new fb.Builder(); | 40         combinators: [ | 
| 54       fb.Offset offset = new UnlinkedNamespaceDirectiveBuilder( | 41           new UnlinkedCombinatorBuilder(isShow: true, names: ['aaa']), | 
| 55           uri: 'package:foo/foo.dart', | 42           new UnlinkedCombinatorBuilder(isShow: false, names: ['bbb', 'ccc']) | 
| 56           combinators: [ | 43         ]).toBytes(); | 
| 57             new UnlinkedCombinatorBuilder(shows: ['aaa']), |  | 
| 58             new UnlinkedCombinatorBuilder(hides: ['bbb', 'ccc']) |  | 
| 59           ]).finish(fbBuilder); |  | 
| 60       bytes = fbBuilder.finish(offset); |  | 
| 61     } |  | 
| 62 | 44 | 
| 63     var directive = new UnlinkedNamespaceDirective(bytes); | 45     var directive = new UnlinkedNamespaceDirective(bytes); | 
| 64     expect(directive.uri, 'package:foo/foo.dart'); | 46     expect(directive.uri, 'package:foo/foo.dart'); | 
| 65     expect(directive.combinators, hasLength(2)); | 47     expect(directive.combinators, hasLength(2)); | 
| 66     expect(directive.combinators[0].shows, ['aaa']); | 48     expect(directive.combinators[0].isShow, isTrue); | 
| 67     expect(directive.combinators[0].hides, isEmpty); | 49     expect(directive.combinators[0].names, ['aaa']); | 
| 68     expect(directive.combinators[1].shows, isEmpty); | 50     expect(directive.combinators[1].isShow, isFalse); | 
| 69     expect(directive.combinators[1].hides, ['bbb', 'ccc']); | 51     expect(directive.combinators[1].names, ['bbb', 'ccc']); | 
| 70   } | 52   } | 
| 71 | 53 | 
| 72   void test_UnlinkedUnit() { | 54   void test_UnlinkedUnit() { | 
| 73     Uint8List bytes; | 55     Uint8List bytes = new UnlinkedUnitBuilder(apiSignature: [ | 
| 74     { | 56       0, | 
| 75       fb.Builder fbBuilder = new fb.Builder(); | 57       1, | 
| 76       fb.Offset offset = new UnlinkedUnitBuilder(apiSignature: [ | 58       2, | 
| 77         0, | 59       3, | 
| 78         1, | 60       4 | 
| 79         2, | 61     ], imports: [ | 
| 80         3, | 62       new UnlinkedNamespaceDirectiveBuilder(uri: 'a.dart') | 
| 81         4 | 63     ], exports: [ | 
| 82       ], imports: [ | 64       new UnlinkedNamespaceDirectiveBuilder(uri: 'b.dart') | 
| 83         new UnlinkedNamespaceDirectiveBuilder(uri: 'a.dart') | 65     ], parts: [ | 
| 84       ], exports: [ | 66       'p1.dart', | 
| 85         new UnlinkedNamespaceDirectiveBuilder(uri: 'b.dart') | 67       'p2.dart', | 
| 86       ], parts: [ | 68     ], hasMixinApplication: true) | 
| 87         new UnlinkedNamespaceDirectiveBuilder(uri: 'p1.dart'), | 69         .toBytes(); | 
| 88         new UnlinkedNamespaceDirectiveBuilder(uri: 'p2.dart'), |  | 
| 89       ], hasMixinApplication: true) |  | 
| 90           .finish(fbBuilder); |  | 
| 91       bytes = fbBuilder.finish(offset); |  | 
| 92     } |  | 
| 93 | 70 | 
| 94     var unit = new UnlinkedUnit(bytes); | 71     var unit = new UnlinkedUnit(bytes); | 
| 95     expect(unit.apiSignature, [0, 1, 2, 3, 4]); | 72     expect(unit.apiSignature, [0, 1, 2, 3, 4]); | 
| 96 | 73 | 
| 97     expect(unit.imports, hasLength(1)); | 74     expect(unit.imports, hasLength(1)); | 
| 98     expect(unit.imports[0].uri, 'a.dart'); | 75     expect(unit.imports[0].uri, 'a.dart'); | 
| 99 | 76 | 
| 100     expect(unit.exports, hasLength(1)); | 77     expect(unit.exports, hasLength(1)); | 
| 101     expect(unit.exports[0].uri, 'b.dart'); | 78     expect(unit.exports[0].uri, 'b.dart'); | 
| 102 | 79 | 
| 103     expect(unit.parts, hasLength(2)); | 80     expect(unit.parts, ['p1.dart', 'p2.dart']); | 
| 104     expect(unit.parts[0].uri, 'p1.dart'); |  | 
| 105     expect(unit.parts[1].uri, 'p2.dart'); |  | 
| 106 | 81 | 
| 107     expect(unit.hasMixinApplication, isTrue); | 82     expect(unit.hasMixinApplication, isTrue); | 
| 108   } | 83   } | 
| 109 | 84 | 
| 110   void test_UnlinkedUnit_hasMixinApplication_false() { | 85   void test_UnlinkedUnit_hasMixinApplication_false() { | 
| 111     Uint8List bytes; | 86     Uint8List bytes = | 
| 112     { | 87         new UnlinkedUnitBuilder(hasMixinApplication: false).toBytes(); | 
| 113       fb.Builder fbBuilder = new fb.Builder(); |  | 
| 114       fb.Offset offset = |  | 
| 115           new UnlinkedUnitBuilder(hasMixinApplication: false).finish(fbBuilder); |  | 
| 116       bytes = fbBuilder.finish(offset); |  | 
| 117     } |  | 
| 118 | 88 | 
| 119     var unit = new UnlinkedUnit(bytes); | 89     var unit = new UnlinkedUnit(bytes); | 
| 120     expect(unit.hasMixinApplication, isFalse); | 90     expect(unit.hasMixinApplication, isFalse); | 
| 121   } | 91   } | 
| 122 } | 92 } | 
| OLD | NEW | 
|---|