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

Side by Side Diff: pkg/polymer/test/transform/common.dart

Issue 23772007: ignore trailing whitespace in polymer transform test (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 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 | « pkg/polymer/test/transform/all_phases_test.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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 polymer.test.transfom.common; 5 library polymer.test.transfom.common;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:barback/barback.dart'; 9 import 'package:barback/barback.dart';
10 import 'package:stack_trace/stack_trace.dart'; 10 import 'package:stack_trace/stack_trace.dart';
11 import 'package:unittest/unittest.dart'; 11 import 'package:unittest/unittest.dart';
12 12
13 String idToString(AssetId id) => '${id.package}|${id.path}'; 13 String idToString(AssetId id) => '${id.package}|${id.path}';
14 AssetId idFromString(String s) { 14 AssetId idFromString(String s) {
15 int index = s.indexOf('|'); 15 int index = s.indexOf('|');
16 return new AssetId(s.substring(0, index), s.substring(index + 1)); 16 return new AssetId(s.substring(0, index), s.substring(index + 1));
17 } 17 }
18 18
19 String _removeTrailingWhitespace(String str) =>
20 str.splitMapJoin('\n',
21 onNonMatch: (s) => s.replaceAll(new RegExp(r'\s+$'), ''));
Jennifer Messerly 2013/09/06 01:36:08 Dart doesn't have a trimEnd, as far as I can tell.
22
19 /** 23 /**
20 * A helper package provider that has files stored in memory, also wraps 24 * A helper package provider that has files stored in memory, also wraps
21 * [Barback] to simply our tests. 25 * [Barback] to simply our tests.
22 */ 26 */
23 class TestHelper implements PackageProvider { 27 class TestHelper implements PackageProvider {
24 /** 28 /**
25 * Maps from an asset string identifier of the form 'package|path' to the 29 * Maps from an asset string identifier of the form 'package|path' to the
26 * file contents. 30 * file contents.
27 */ 31 */
28 final Map<String, String> files; 32 final Map<String, String> files;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 barback.updateSources(paths.map(idFromString)); 71 barback.updateSources(paths.map(idFromString));
68 } 72 }
69 73
70 Future<String> operator [](String assetString){ 74 Future<String> operator [](String assetString){
71 return barback.getAssetById(idFromString(assetString)) 75 return barback.getAssetById(idFromString(assetString))
72 .then((asset) => asset.readAsString()); 76 .then((asset) => asset.readAsString());
73 } 77 }
74 78
75 Future check(String assetIdString, String content) { 79 Future check(String assetIdString, String content) {
76 return this[assetIdString].then((value) { 80 return this[assetIdString].then((value) {
81 value = _removeTrailingWhitespace(value);
82 content = _removeTrailingWhitespace(content);
77 expect(value, content, reason: 'Final output of $assetIdString differs.'); 83 expect(value, content, reason: 'Final output of $assetIdString differs.');
78 }); 84 });
79 } 85 }
80 86
81 Future checkAll(Map<String, String> files) { 87 Future checkAll(Map<String, String> files) {
82 var futures = []; 88 var futures = [];
83 files.forEach((k, v) { 89 files.forEach((k, v) {
84 futures.add(check(k, v)); 90 futures.add(check(k, v));
85 }); 91 });
86 return Future.wait(futures); 92 return Future.wait(futures);
87 } 93 }
88 } 94 }
89 95
90 testPhases(String testName, List<List<Transformer>> phases, 96 testPhases(String testName, List<List<Transformer>> phases,
91 Map<String, String> inputFiles, Map<String, String> expectedFiles) { 97 Map<String, String> inputFiles, Map<String, String> expectedFiles) {
92 test(testName, () { 98 test(testName, () {
93 var helper = new TestHelper(phases, inputFiles)..run(); 99 var helper = new TestHelper(phases, inputFiles)..run();
94 return helper.checkAll(expectedFiles).then((_) => helper.tearDown()); 100 return helper.checkAll(expectedFiles).then((_) => helper.tearDown());
95 }); 101 });
96 } 102 }
97 103
98 // TODO(jmesserly): this is .debug to workaround issue 13046. 104 // TODO(jmesserly): this is .debug to workaround issue 13046.
99 const SHADOW_DOM_TAG = 105 const SHADOW_DOM_TAG =
100 '<script src="packages/shadow_dom/shadow_dom.debug.js"></script>\n'; 106 '<script src="packages/shadow_dom/shadow_dom.debug.js"></script>\n';
101 107
102 const INTEROP_TAG = '<script src="packages/browser/interop.js"></script>\n'; 108 const INTEROP_TAG = '<script src="packages/browser/interop.js"></script>\n';
103 109
104 const PKG_JS_INTEROP_TAG = 110 const PKG_JS_INTEROP_TAG =
105 '<script src="packages/js/dart_interop.js"></script>\n'; 111 '<script src="packages/js/dart_interop.js"></script>\n';
OLDNEW
« no previous file with comments | « pkg/polymer/test/transform/all_phases_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698