dart-sdk/pkg/smith/test/test_helpers.dart
Karl Klose 23fa59f8b6 [infra] Add support for builders to pkg/smith
Change-Id: I21b970aaa61331b25687891f325621165f7861ad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128160
Commit-Queue: Karl Klose <karlklose@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
2020-01-27 08:13:25 +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, 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));
}
}