OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2016, 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 /// A message emitted by a test. |
| 6 /// |
| 7 /// A message encompasses any textual information that should be presented to |
| 8 /// the user. Reporters are encouraged to visually distinguish different message |
| 9 /// types. |
| 10 class Message { |
| 11 final MessageType type; |
| 12 |
| 13 final String text; |
| 14 |
| 15 Message(this.type, this.text); |
| 16 |
| 17 Message.print(this.text) : type = MessageType.print; |
| 18 Message.skip(this.text) : type = MessageType.skip; |
| 19 } |
| 20 |
| 21 class MessageType { |
| 22 /// A message explicitly printed by the user's test. |
| 23 static const print = const MessageType._("print"); |
| 24 |
| 25 /// A message indicating that a test, or some portion of one, was skipped. |
| 26 static const skip = const MessageType._("skip"); |
| 27 |
| 28 /// The name of the message type. |
| 29 final String name; |
| 30 |
| 31 factory MessageType.parse(String name) { |
| 32 switch (name) { |
| 33 case "print": return MessageType.print; |
| 34 case "skip": return MessageType.skip; |
| 35 default: throw new ArgumentError('Invalid message type "$name".'); |
| 36 } |
| 37 } |
| 38 |
| 39 const MessageType._(this.name); |
| 40 |
| 41 String toString() => name; |
| 42 } |
OLD | NEW |