Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(420)

Unified Diff: sdk/lib/_internal/pub_generated/test/preprocess_test.dart

Issue 657673002: Regenerate pub sources. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/pub_generated/test/preprocess_test.dart
diff --git a/sdk/lib/_internal/pub_generated/test/preprocess_test.dart b/sdk/lib/_internal/pub_generated/test/preprocess_test.dart
index 0f8bc6586fdfcfdb311a5b06219a83400afac738..0cd4eadd0d041d4aab5b5890f03590e927fabc86 100644
--- a/sdk/lib/_internal/pub_generated/test/preprocess_test.dart
+++ b/sdk/lib/_internal/pub_generated/test/preprocess_test.dart
@@ -1,10 +1,18 @@
+// Copyright (c) 2014, 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.
+
library pub.test.preprocess_test;
+
import 'package:pub_semver/pub_semver.dart';
import 'package:unittest/unittest.dart';
+
import '../lib/src/preprocess.dart';
import 'test_pub.dart';
+
main() {
initConfig();
+
test("does nothing on a file without preprocessor directives", () {
var text = '''
some text
@@ -12,11 +20,14 @@ some text
// #
//# not beginning of line
''';
+
expect(_preprocess(text), equals(text));
});
+
test("allows bare insert directive", () {
expect(_preprocess('//> foo'), equals('foo'));
});
+
test("allows empty insert directive", () {
expect(_preprocess('''
//> foo
@@ -24,6 +35,7 @@ some text
//> bar
'''), equals('foo\n\nbar\n'));
});
+
group("if", () {
group("with a version range", () {
test("removes sections with non-matching versions", () {
@@ -38,6 +50,7 @@ before
after
'''));
});
+
test("doesn't insert section with non-matching versions", () {
expect(_preprocess('''
before
@@ -50,6 +63,7 @@ before
after
'''));
});
+
test("doesn't remove sections with matching versions", () {
expect(_preprocess('''
before
@@ -63,6 +77,7 @@ inside
after
'''));
});
+
test("inserts sections with matching versions", () {
expect(_preprocess('''
before
@@ -76,6 +91,7 @@ inside
after
'''));
});
+
test("allows multi-element version ranges", () {
expect(_preprocess('''
before
@@ -93,6 +109,7 @@ after
'''));
});
});
+
group("with a package name", () {
test("removes sections for a nonexistent package", () {
expect(_preprocess('''
@@ -106,6 +123,7 @@ before
after
'''));
});
+
test("doesn't insert sections for a nonexistent package", () {
expect(_preprocess('''
before
@@ -118,6 +136,7 @@ before
after
'''));
});
+
test("doesn't remove sections with an existent package", () {
expect(_preprocess('''
before
@@ -131,6 +150,7 @@ inside
after
'''));
});
+
test("inserts sections with an existent package", () {
expect(_preprocess('''
before
@@ -146,6 +166,7 @@ after
});
});
});
+
group("else", () {
test("removes non-matching sections", () {
expect(_preprocess('''
@@ -162,6 +183,7 @@ inside 1
after
'''));
});
+
test("doesn't insert non-matching sections", () {
expect(_preprocess('''
before
@@ -177,6 +199,7 @@ inside 1
after
'''));
});
+
test("doesn't remove matching sections", () {
expect(_preprocess('''
before
@@ -192,6 +215,7 @@ inside 2
after
'''));
});
+
test("inserts matching sections", () {
expect(_preprocess('''
before
@@ -208,35 +232,43 @@ after
'''));
});
});
+
group("errors", () {
test("disallows unknown statements", () {
expect(() => _preprocess('//# foo bar\n//# end'), throwsFormatException);
});
+
test("disallows insert directive without space", () {
expect(() => _preprocess('//>foo'), throwsFormatException);
});
+
group("if", () {
test("disallows if with no arguments", () {
expect(() => _preprocess('//# if\n//# end'), throwsFormatException);
});
+
test("disallows if with no package", () {
expect(
() => _preprocess('//# if <=1.0.0\n//# end'),
throwsFormatException);
});
+
test("disallows invalid version constraint", () {
expect(
() => _preprocess('//# if barback >=1.0\n//# end'),
throwsFormatException);
});
+
test("disallows dangling end", () {
expect(() => _preprocess('//# end'), throwsFormatException);
});
+
test("disallows if without end", () {
expect(
() => _preprocess('//# if barback >=1.0.0'),
throwsFormatException);
});
+
test("disallows nested if", () {
expect(() => _preprocess('''
//# if barback >=1.0.0
@@ -246,15 +278,18 @@ after
'''), throwsFormatException);
});
});
+
group("else", () {
test("disallows else without if", () {
expect(() => _preprocess('//# else\n//# end'), throwsFormatException);
});
+
test("disallows else without end", () {
expect(
() => _preprocess('//# if barback >=1.0.0\n//# else'),
throwsFormatException);
});
+
test("disallows else with an argument", () {
expect(() => _preprocess('''
//# if barback >=1.0.0
@@ -265,6 +300,7 @@ after
});
});
}
+
String _preprocess(String input) => preprocess(input, {
'barback': new Version.parse("1.2.3")
}, 'source/url');

Powered by Google App Engine
This is Rietveld 408576698