Files
sdk/pkg/smith/test/test_helpers.dart
T
Devon Carew 317e3463a6 [pkg] use package:lints when analyzing pkg/smith, pkg/expect
Change-Id: Iaaf2f8a1583ea94fadb8cb03fd83dc9ed38b2b95
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/250771
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2022-07-06 22:29:24 +00:00

39 lines
1.2 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:expect/minitest.dart';
import 'package:smith/smith.dart';
void expectParseError(String name, Map<String, dynamic> options, String error) {
try {
var configuration = Configuration.parse(name, options);
fail("Expected FormatException but got $configuration.");
} on FormatException catch (ex) {
expect(ex.message, equals(error));
}
}
void expectFormatError(String error, Function() test) {
try {
test();
} on FormatException catch (e) {
expect(e.message, equals(error));
// This is the exception we expected, do nothing.
return;
} catch (e) {
fail("Expected FormatException '$error' but got ${e.runtimeType}: $e");
}
fail("Expected exception '$error' did not occur");
}
void expectExpandError(
String template, Map<String, dynamic> options, String error) {
try {
var configurations = Configuration.expandTemplate(template, options);
fail("Expected FormatException but got $configurations.");
} on FormatException catch (ex) {
expect(ex.message, equals(error));
}
}