|
| 1 | +// Copyright (c) 2019, 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 | +import 'package:analyzer/src/error/codes.dart'; |
| 6 | +import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| 7 | + |
| 8 | +import '../dart/resolution/driver_resolution.dart'; |
| 9 | + |
| 10 | +main() { |
| 11 | + defineReflectiveSuite(() { |
| 12 | + defineReflectiveTests(InvalidUriTest); |
| 13 | + }); |
| 14 | +} |
| 15 | + |
| 16 | +@reflectiveTest |
| 17 | +class InvalidUriTest extends DriverResolutionTest { |
| 18 | + test_emptyUri() async { |
| 19 | + await assertNoErrorsInCode(''' |
| 20 | +import '' as top; |
| 21 | +int x; |
| 22 | +class C { |
| 23 | + int x; |
| 24 | + int get y => top.x; // ref |
| 25 | +} |
| 26 | +'''); |
| 27 | + assertElement(findNode.simple('x; // ref'), findElement.topGet('x')); |
| 28 | + } |
| 29 | + |
| 30 | + test_invalidScheme_export() async { |
| 31 | + await assertErrorsInCode(''' |
| 32 | +export 'ht:'; |
| 33 | +''', [ |
| 34 | + error(CompileTimeErrorCode.INVALID_URI, 7, 5), |
| 35 | + ]); |
| 36 | + } |
| 37 | + |
| 38 | + test_invalidScheme_import() async { |
| 39 | + await assertErrorsInCode(''' |
| 40 | +import 'ht:'; |
| 41 | +''', [ |
| 42 | + error(CompileTimeErrorCode.INVALID_URI, 7, 5), |
| 43 | + ]); |
| 44 | + } |
| 45 | + |
| 46 | + test_invalidScheme_part() async { |
| 47 | + await assertErrorsInCode(r''' |
| 48 | +part 'ht:'; |
| 49 | +''', [ |
| 50 | + error(CompileTimeErrorCode.INVALID_URI, 5, 5), |
| 51 | + ]); |
| 52 | + } |
| 53 | +} |
0 commit comments