Skip to content

Commit

Permalink
move valid_regexps tests (#4565)
Browse files Browse the repository at this point in the history
* move valid_regexps tests

* Update test/rules/valid_regexps_test.dart

Co-authored-by: Albert Mañosa <[email protected]>

---------

Co-authored-by: Albert Mañosa <[email protected]>
  • Loading branch information
srawlins and albertms10 authored Jul 17, 2023
1 parent ad42f65 commit d762056
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 14 deletions.
2 changes: 2 additions & 0 deletions test/rules/all.dart
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ import 'use_setters_to_change_properties_test.dart'
as use_setters_to_change_properties;
import 'use_super_parameters_test.dart' as use_super_parameters;
import 'use_test_throws_matchers_test.dart' as use_test_throws_matchers;
import 'valid_regexps_test.dart' as valid_regexps;
import 'void_checks_test.dart' as void_checks;

void main() {
Expand Down Expand Up @@ -330,5 +331,6 @@ void main() {
use_setters_to_change_properties.main();
use_super_parameters.main();
use_test_throws_matchers.main();
valid_regexps.main();
void_checks.main();
}
49 changes: 49 additions & 0 deletions test/rules/valid_regexps_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copyright (c) 2023, 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:test_reflective_loader/test_reflective_loader.dart';

import '../rule_test_support.dart';

main() {
defineReflectiveSuite(() {
defineReflectiveTests(ValidRegexpsTest);
});
}

@reflectiveTest
class ValidRegexpsTest extends LintRuleTest {
@override
String get lintRule => 'valid_regexps';

test_emojis() async {
// https://stackoverflow.com/questions/61151471/regexp-for-unicode-13-emojis
await assertNoDiagnostics(r'''
var e = RegExp(
r'(\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])',
unicode: true);
''');
}

test_interpolation() async {
await assertNoDiagnostics(r'''
var r = '';
var s = RegExp('( $r');
''');
}

test_invalid() async {
await assertDiagnostics(r'''
var s = RegExp('(');
''', [
lint(15, 3),
]);
}

test_valid() async {
await assertNoDiagnostics(r'''
var s = RegExp('[(]');
''');
}
}
14 changes: 0 additions & 14 deletions test_data/rules/valid_regexps.dart

This file was deleted.

0 comments on commit d762056

Please sign in to comment.