4ff04f641b
Change-Id: Icdcc648f42393b28daf648f752e3b4d61f51aa10 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212043 Commit-Queue: Johnni Winther <johnniwinther@google.com> Reviewed-by: Jens Johansen <jensj@google.com>
31 lines
1.0 KiB
Dart
31 lines
1.0 KiB
Dart
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
import 'package:kernel/binary/ast_from_binary.dart' show ParseError;
|
|
|
|
import 'utils.dart';
|
|
|
|
void main() {
|
|
Uri uri = Uri.parse("foo://bar.dart");
|
|
Library lib1 = new Library(uri, fileUri: uri);
|
|
Component c1 = new Component(libraries: [lib1]);
|
|
List<int> serialized = serializeComponent(c1);
|
|
// The last 4 bytes is the size entry in the index. Overwrite that with 0's.
|
|
for (int i = serialized.length - 4; i < serialized.length; i++) {
|
|
serialized[i] = 0;
|
|
}
|
|
bool gotExpectedException = false;
|
|
try {
|
|
loadComponentFromBytes(serialized);
|
|
throw "The above line should have thrown.";
|
|
} on ParseError catch (e) {
|
|
if (e.toString().contains("invalid size")) {
|
|
gotExpectedException = true;
|
|
}
|
|
}
|
|
if (!gotExpectedException) {
|
|
throw "Didn't get the right exception!";
|
|
}
|
|
}
|