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

Side by Side Diff: sdk/lib/_internal/pub/test/pubspec_test.dart

Issue 23295025: Handle invalid version syntax in pubspecs. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Refactor a bit. Created 7 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/pubspec.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 library pubspec_test; 5 library pubspec_test;
6 6
7 import 'package:unittest/unittest.dart'; 7 import 'package:unittest/unittest.dart';
8 8
9 import '../lib/src/pubspec.dart'; 9 import '../lib/src/pubspec.dart';
10 import '../lib/src/source.dart'; 10 import '../lib/src/source.dart';
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 }); 104 });
105 105
106 test("throws if the description isn't valid", () { 106 test("throws if the description isn't valid", () {
107 expectFormatError(''' 107 expectFormatError('''
108 dependencies: 108 dependencies:
109 foo: 109 foo:
110 mock: bad 110 mock: bad
111 '''); 111 ''');
112 }); 112 });
113 113
114 test("throws if dependency version is not a string", () {
115 expectFormatError('''
116 dependencies:
117 foo:
118 mock: ok
119 version: 1.2
120 ''');
121 });
122
123 test("throws if version is not a version constraint", () {
124 expectFormatError('''
125 dependencies:
126 foo:
127 mock: ok
128 version: not constraint
129 ''');
130 });
131
114 test("throws if 'name' is not a string", () { 132 test("throws if 'name' is not a string", () {
115 expectFormatError('name: [not, a, string]'); 133 expectFormatError('name: [not, a, string]');
116 }); 134 });
117 135
136 test("throws if version is not a string", () {
137 expectFormatError('''
138 version: 1.0
139 ''');
140 });
141
142 test("throws if version is not a version", () {
143 expectFormatError('''
144 version: not version
145 ''');
146 });
147
118 test("throws if 'homepage' is not a string", () { 148 test("throws if 'homepage' is not a string", () {
119 expectFormatError('homepage:'); 149 expectFormatError('homepage:');
120 expectFormatError('homepage: [not, a, string]'); 150 expectFormatError('homepage: [not, a, string]');
121 }); 151 });
122 152
123 test("throws if 'homepage' doesn't have an HTTP scheme", () { 153 test("throws if 'homepage' doesn't have an HTTP scheme", () {
124 new Pubspec.parse(null, 'homepage: http://ok.com', sources); 154 new Pubspec.parse(null, 'homepage: http://ok.com', sources);
125 new Pubspec.parse(null, 'homepage: https://also-ok.com', sources); 155 new Pubspec.parse(null, 'homepage: https://also-ok.com', sources);
126 156
127 expectFormatError('homepage: ftp://badscheme.com'); 157 expectFormatError('homepage: ftp://badscheme.com');
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 equals(new VersionConstraint.parse(">=1.2.3 <2.3.4"))); 235 equals(new VersionConstraint.parse(">=1.2.3 <2.3.4")));
206 }); 236 });
207 237
208 test("throws if the sdk isn't a string", () { 238 test("throws if the sdk isn't a string", () {
209 expectFormatError(''' 239 expectFormatError('''
210 environment: 240 environment:
211 sdk: [] 241 sdk: []
212 '''); 242 ''');
213 }); 243 });
214 244
245 test("throws if the sdk is not a string", () {
246 expectFormatError('''
247 environment:
248 sdk: 1.0
249 ''');
250 });
251
215 test("throws if the sdk isn't a valid version constraint", () { 252 test("throws if the sdk isn't a valid version constraint", () {
216 expectFormatError(''' 253 expectFormatError('''
217 environment: 254 environment:
218 sdk: "oopies" 255 sdk: "oopies"
219 '''); 256 ''');
220 }); 257 });
221 }); 258 });
222 }); 259 });
223 } 260 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/pubspec.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698