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

Unified Diff: pkg/csslib/test/transform/simple_test.dart

Issue 23576012: Added .scss transform (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: cleanup 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 side-by-side diff with in-line comments
Download patch
Index: pkg/csslib/test/transform/simple_test.dart
diff --git a/pkg/csslib/test/transform/simple_test.dart b/pkg/csslib/test/transform/simple_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..a261bb7740291342793f16f2f17684a8b1a6a890
--- /dev/null
+++ b/pkg/csslib/test/transform/simple_test.dart
@@ -0,0 +1,192 @@
+// Copyright (c) 2013, 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 csslib.test.transform.simple_test;
+
+import 'package:csslib/transform.dart';
+import 'package:unittest/compact_vm_config.dart';
+
+import 'common.dart';
+
+void testPseudo() {
+ testSass('Pseudo', r"""
+html:lang(fr-ca) { quotes: '" ' ' "' }
+zoom: { }
+
+a:link { color: red }
+:link { color: blue }
+
+a:focus { background: yellow }
+a:focus:hover { background: white }
+
+p.special:first-letter {color: #ffd800}
+
+p:not(#example){
+ background-color: yellow;
+}
+
+input:not([DISABLED]){
+ background-color: yellow;
+}
+
+html|*:not(:link):not(:visited) {
+ border: 1px solid black;
+}
+
+*:not(FOO) {
+ height: 20px;
+}
+
+*|*:not(*) {
+ color: orange;
+}
+
+*|*:not(:hover) {
+ color: magenta;
+}
+
+p:nth-child(3n-3) { }
+
+div:nth-child(2n) { color : red; }
+""", r"""html:lang(fr-ca) {
+ quotes: "\" " " \"";
+}
+zoom {
+}
+a:link {
+ color: #f00;
+}
+:link {
+ color: #00f;
+}
+a:focus {
+ background: #ff0;
+}
+a:focus:hover {
+ background: #fff;
+}
+p.special:first-letter {
+ color: #ffd800;
+}
+p:not(#example) {
+ background-color: #ff0;
+}
+input:not([DISABLED]) {
+ background-color: #ff0;
+}
+html|*:not(:link):not(:visited) {
+ border: 1px solid #000;
+}
+*:not(FOO) {
+ height: 20px;
+}
+*|*:not(*) {
+ color: #ffa500;
+}
+*|*:not(:hover) {
+ color: #f0f;
+}
+p:nth-child(3n-3) {
+}
+div:nth-child(2n) {
+ color: #f00;
+}""");
+}
+
+void testHost() {
+ var input = r"""
+@host {
+ :scope {
+ white-space: nowrap;
+ overflow-style: marquee-line;
+ overflow-x: marquee;
+ }
+ * { color: red; }
+ *:hover { font-weight: bold; }
+ :nth-child(odd) { color: blue; }
+};""";
+var expected = r"""
+@host {
+:scope {
+ white-space: nowrap;
+ overflow-style: marquee-line;
+ overflow-x: marquee;
+}
+* {
+ color: #f00;
+}
+*:hover {
+ font-weight: bold;
+}
+:nth-child(odd) {
+ color: #00f;
+}
+}""";
+ testSass("@host", input, expected);
+}
+
+// TODO(terry): Move to emitter_test.dart when real emitter exist.
+void testEmitter() {
+ var errors = [];
+ var input = r"""
+.foo {
+ color: red; left: 20px; top: 20px; width: 100px; height:200px
+ }
+#div {
+ color : #00F578; border-color: #878787;
+}""";
+ var expected = r"""
+.foo {
+ color: #f00;
+ left: 20px;
+ top: 20px;
+ width: 100px;
+ height: 200px;
+}
+#div {
+ color: #00F578;
+ border-color: #878787;
+}""";
+ testSass("Emitter", input, expected);
+}
+
+void testSimple() {
+ var input = r"""
+.foo {
+ color: red; left: 20px; top: 20px; width: 100px; height:200px
+ }
+#div {
+ color : #00F578; border-color: #878787;
+}""";
+ var expected = r""".foo {
+ color: #f00;
+ left: 20px;
+ top: 20px;
+ width: 100px;
+ height: 200px;
+}
+#div {
+ color: #00F578;
+ border-color: #878787;
+}""";
+ testSass('Simple', input, expected);
+}
+
+testSass(String testName, String inputFile, String expectedFile) {
+ var transform = new ScssTransformer();
+ expectedFile = "/***** Generated by SCSS transform. *****/\n\n$expectedFile";
+ testPhases(testName, [[transform]], { 'a|web/test.scss' : inputFile },
+ { 'a|web/test.css' : expectedFile });
+ // TODO(terry): Test for any errors reported in logger.
+}
+
+void main() {
+ useCompactVMConfiguration();
+
+ testSimple();
+ testPseudo();
+ testHost();
+ testEmitter();
+}
+

Powered by Google App Engine
This is Rietveld 408576698