blob: d2150c933b9a40b26114cd3dc13a83ec4643c137 [file] [log] [blame]
// Copyright (c) 2015, 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:linter/src/ast.dart';
import 'package:test/test.dart';
import 'util/test_utils.dart';
void main() {
group('rule tests', () {
setUp(setUpSharedTestEnvironment);
defineRuleUnitTests();
});
}
void defineRuleUnitTests() {
group('names', () {
group('keywords', () {
var good = ['class', 'if', 'assert', 'catch', 'import'];
testEach(good, isKeyWord, isTrue);
var bad = ['_class', 'iff', 'assert_', 'Catch'];
testEach(bad, isKeyWord, isFalse);
});
group('identifiers', () {
var good = [
'foo',
'_if',
'_',
'f2',
'fooBar',
'foo_bar',
'\$foo',
'foo\$Bar',
'foo\$',
];
testEach(good, isValidDartIdentifier, isTrue);
var bad = ['if', '42', '3', '2f'];
testEach(bad, isValidDartIdentifier, isFalse);
});
});
}