| OLD | NEW | 
|---|
| 1 // Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 // This file is for matcher tests that rely on the names of various Dart types. | 5 // This file is for matcher tests that rely on the names of various Dart types. | 
| 6 // These tests normally fail when run in minified dart2js, since the names will | 6 // These tests normally fail when run in minified dart2js, since the names will | 
| 7 // be mangled. This version of the file is modified to expect minified names. | 7 // be mangled. This version of the file is modified to expect minified names. | 
| 8 | 8 | 
| 9 import 'package:unittest/unittest.dart'; | 9 import 'package:unittest/unittest.dart'; | 
| 10 | 10 | 
| 11 import 'test_common.dart'; | 11 import 'test_common.dart'; | 
| 12 import 'test_utils.dart'; | 12 import 'test_utils.dart'; | 
| 13 | 13 | 
| 14 // A regexp fragment matching a minified name. | 14 // A regexp fragment matching a minified name. | 
| 15 final _minifiedName = r"[A-Za-z0-9]{1,3}"; | 15 final _minifiedName = r"[A-Za-z0-9]{1,3}"; | 
| 16 | 16 | 
| 17 void main() { | 17 void main() { | 
| 18   initUtils(); | 18   initUtils(); | 
| 19 | 19 | 
| 20   group('Core matchers', () { | 20   group('Core matchers', () { | 
| 21     test('throwsFormatException', () { | 21     test('throwsFormatException', () { | 
| 22       shouldPass(() { throw new FormatException(''); }, | 22       shouldPass(() { throw new FormatException(''); }, | 
| 23           throwsFormatException); | 23           throwsFormatException); | 
| 24       shouldFail(() { throw new Exception(); }, | 24       shouldFail(() { throw new Exception(); }, | 
| 25           throwsFormatException, | 25           throwsFormatException, | 
| 26           matches( | 26           matches( | 
| 27               r"Expected: throws FormatException +" | 27               r"Expected: throws FormatException +" | 
| 28               r"Actual: <Closure(: \(dynamic\) => dynamic)?> +" | 28               r"Actual: <Closure(: \(\) => dynamic)?> +" | 
| 29               r"Which: threw " + _minifiedName + r":<Exception>")); | 29               r"Which: threw " + _minifiedName + r":<Exception>")); | 
| 30     }); | 30     }); | 
| 31 | 31 | 
| 32     test('throwsArgumentError', () { | 32     test('throwsArgumentError', () { | 
| 33       shouldPass(() { throw new ArgumentError(''); }, | 33       shouldPass(() { throw new ArgumentError(''); }, | 
| 34           throwsArgumentError); | 34           throwsArgumentError); | 
| 35       shouldFail(() { throw new Exception(); }, | 35       shouldFail(() { throw new Exception(); }, | 
| 36           throwsArgumentError, | 36           throwsArgumentError, | 
| 37           matches( | 37           matches( | 
| 38               r"Expected: throws ArgumentError +" | 38               r"Expected: throws ArgumentError +" | 
| 39               r"Actual: <Closure(: \(dynamic\) => dynamic)?> +" | 39               r"Actual: <Closure(: \(\) => dynamic)?> +" | 
| 40               r"Which: threw " + _minifiedName + r":<Exception>")); | 40               r"Which: threw " + _minifiedName + r":<Exception>")); | 
| 41     }); | 41     }); | 
| 42 | 42 | 
| 43     test('throwsRangeError', () { | 43     test('throwsRangeError', () { | 
| 44       shouldPass(() { throw new RangeError(0); }, | 44       shouldPass(() { throw new RangeError(0); }, | 
| 45           throwsRangeError); | 45           throwsRangeError); | 
| 46       shouldFail(() { throw new Exception(); }, | 46       shouldFail(() { throw new Exception(); }, | 
| 47           throwsRangeError, | 47           throwsRangeError, | 
| 48           matches( | 48           matches( | 
| 49               r"Expected: throws RangeError +" | 49               r"Expected: throws RangeError +" | 
| 50               r"Actual: <Closure(: \(dynamic\) => dynamic)?> +" | 50               r"Actual: <Closure(: \(\) => dynamic)?> +" | 
| 51               r"Which: threw " + _minifiedName + r":<Exception>")); | 51               r"Which: threw " + _minifiedName + r":<Exception>")); | 
| 52     }); | 52     }); | 
| 53 | 53 | 
| 54     test('throwsNoSuchMethodError', () { | 54     test('throwsNoSuchMethodError', () { | 
| 55       shouldPass(() { throw new NoSuchMethodError(null, '', null, null); }, | 55       shouldPass(() { throw new NoSuchMethodError(null, '', null, null); }, | 
| 56           throwsNoSuchMethodError); | 56           throwsNoSuchMethodError); | 
| 57       shouldFail(() { throw new Exception(); }, | 57       shouldFail(() { throw new Exception(); }, | 
| 58           throwsNoSuchMethodError, | 58           throwsNoSuchMethodError, | 
| 59           matches( | 59           matches( | 
| 60               r"Expected: throws NoSuchMethodError +" | 60               r"Expected: throws NoSuchMethodError +" | 
| 61               r"Actual: <Closure(: \(dynamic\) => dynamic)?> +" | 61               r"Actual: <Closure(: \(\) => dynamic)?> +" | 
| 62               r"Which: threw " + _minifiedName + r":<Exception>")); | 62               r"Which: threw " + _minifiedName + r":<Exception>")); | 
| 63     }); | 63     }); | 
| 64 | 64 | 
| 65     test('throwsUnimplementedError', () { | 65     test('throwsUnimplementedError', () { | 
| 66       shouldPass(() { throw new UnimplementedError(''); }, | 66       shouldPass(() { throw new UnimplementedError(''); }, | 
| 67           throwsUnimplementedError); | 67           throwsUnimplementedError); | 
| 68       shouldFail(() { throw new Exception(); }, | 68       shouldFail(() { throw new Exception(); }, | 
| 69           throwsUnimplementedError, | 69           throwsUnimplementedError, | 
| 70           matches( | 70           matches( | 
| 71               r"Expected: throws UnimplementedError +" | 71               r"Expected: throws UnimplementedError +" | 
| 72               r"Actual: <Closure(: \(dynamic\) => dynamic)?> +" | 72               r"Actual: <Closure(: \(\) => dynamic)?> +" | 
| 73               r"Which: threw " + _minifiedName + r":<Exception>")); | 73               r"Which: threw " + _minifiedName + r":<Exception>")); | 
| 74     }); | 74     }); | 
| 75 | 75 | 
| 76     test('throwsUnsupportedError', () { | 76     test('throwsUnsupportedError', () { | 
| 77       shouldPass(() { throw new UnsupportedError(''); }, | 77       shouldPass(() { throw new UnsupportedError(''); }, | 
| 78           throwsUnsupportedError); | 78           throwsUnsupportedError); | 
| 79       shouldFail(() { throw new Exception(); }, | 79       shouldFail(() { throw new Exception(); }, | 
| 80           throwsUnsupportedError, | 80           throwsUnsupportedError, | 
| 81           matches( | 81           matches( | 
| 82               r"Expected: throws UnsupportedError +" | 82               r"Expected: throws UnsupportedError +" | 
| 83               r"Actual: <Closure(: \(dynamic\) => dynamic)?> +" | 83               r"Actual: <Closure(: \(\) => dynamic)?> +" | 
| 84               r"Which: threw " + _minifiedName + r":<Exception>")); | 84               r"Which: threw " + _minifiedName + r":<Exception>")); | 
| 85     }); | 85     }); | 
| 86 | 86 | 
| 87     test('throwsStateError', () { | 87     test('throwsStateError', () { | 
| 88       shouldPass(() { throw new StateError(''); }, | 88       shouldPass(() { throw new StateError(''); }, | 
| 89           throwsStateError); | 89           throwsStateError); | 
| 90       shouldFail(() { throw new Exception(); }, | 90       shouldFail(() { throw new Exception(); }, | 
| 91           throwsStateError, | 91           throwsStateError, | 
| 92           matches( | 92           matches( | 
| 93               r"Expected: throws StateError +" | 93               r"Expected: throws StateError +" | 
| 94               r"Actual: <Closure(: \(dynamic\) => dynamic)?> +" | 94               r"Actual: <Closure(: \(\) => dynamic)?> +" | 
| 95               r"Which: threw " + _minifiedName + r":<Exception>")); | 95               r"Which: threw " + _minifiedName + r":<Exception>")); | 
| 96     }); | 96     }); | 
| 97   }); | 97   }); | 
| 98 | 98 | 
| 99   group('Iterable Matchers', () { | 99   group('Iterable Matchers', () { | 
| 100     test('isEmpty', () { | 100     test('isEmpty', () { | 
| 101       var d = new SimpleIterable(0); | 101       var d = new SimpleIterable(0); | 
| 102       var e = new SimpleIterable(1); | 102       var e = new SimpleIterable(1); | 
| 103       shouldPass(d, isEmpty); | 103       shouldPass(d, isEmpty); | 
| 104       shouldFail(e, isEmpty, | 104       shouldFail(e, isEmpty, | 
| (...skipping 19 matching lines...) Expand all  Loading... | 
| 124       shouldFail(w, new HasPrice(greaterThan(10)), | 124       shouldFail(w, new HasPrice(greaterThan(10)), | 
| 125           matches( | 125           matches( | 
| 126               r"Expected: Widget with a price that is a value greater than " | 126               r"Expected: Widget with a price that is a value greater than " | 
| 127                   r"<10> +" | 127                   r"<10> +" | 
| 128               r"Actual: <Instance of '" + _minifiedName + r"'> +" | 128               r"Actual: <Instance of '" + _minifiedName + r"'> +" | 
| 129               r"Which: has price with value <10> which is not " | 129               r"Which: has price with value <10> which is not " | 
| 130               r"a value greater than <10>")); | 130               r"a value greater than <10>")); | 
| 131     }); | 131     }); | 
| 132   }); | 132   }); | 
| 133 } | 133 } | 
| OLD | NEW | 
|---|