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

Side by Side Diff: lib/src/prism/tests/testrunner-tests.js

Issue 1418513006: update elements and fix some bugs (Closed) Base URL: git@github.com:dart-lang/polymer_elements.git@master
Patch Set: code review updates Created 5 years, 1 month 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
« no previous file with comments | « lib/src/prism/tests/run.js ('k') | lib/src/prism/themes/prism.css » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 "use strict";
2
3 var assert = require("chai").assert;
4 var TokenStreamTransformer = require("./helper/token-stream-transformer");
5 var TestCase = require("./helper/test-case");
6
7
8 //region Token Stream Transformer
9 describe("The token stream transformer",
10 function () {
11 it("should handle all kinds of simple transformations",
12 function () {
13 var tokens = [
14 {type: "type", content: "content"},
15 "string"
16 ];
17
18 var expected = [
19 ["type", "content"],
20 "string"
21 ];
22
23 assert.deepEqual(TokenStreamTransformer.simplify (tokens), expected);
24 }
25 );
26
27
28 it("should handle nested structures",
29 function () {
30 var tokens = [
31 {
32 type: "type",
33 content: [
34 {
35 type: "insideTyp e", content:
36 [
37 {type: " insideInsideType", content: "content"}
38 ]
39 }
40 ]
41 }
42 ];
43
44 var expected = [
45 ["type", [
46 ["insideType", [
47 ["insideInsideType", "co ntent"]
48 ]]
49 ]]
50 ];
51
52 assert.deepEqual(TokenStreamTransformer.simplify (tokens), expected);
53 }
54 );
55
56
57 it("should strip empty tokens",
58 function () {
59 var tokenStream = [
60 "",
61 "\r\n",
62 "\t",
63 " "
64 ];
65
66 var expectedSimplified = [];
67
68 assert.deepEqual(TokenStreamTransformer.simplify (tokenStream), expectedSimplified);
69 }
70 );
71
72
73 it("should strip empty token tree branches",
74 function () {
75 var tokenStream = [
76 {
77 type: "type",
78 content: [
79 ["", ""],
80 "",
81 {type: "nested", content : [""]}
82 ]
83 },
84 [[[[[[[""]]]]]]]
85 ];
86
87 var expectedSimplified = [
88 ["type", [
89 ["nested", []]
90 ]]
91 ];
92
93 assert.deepEqual(TokenStreamTransformer.simplify (tokenStream), expectedSimplified);
94 }
95 );
96
97
98 it("should ignore all properties in tokens except value and cont ent",
99 function () {
100
101 var tokenStream = [
102 {type: "type", content: "content", alias : "alias"}
103 ];
104
105 var expectedSimplified = [
106 ["type", "content"]
107 ];
108
109 assert.deepEqual(TokenStreamTransformer.simplify (tokenStream), expectedSimplified);
110 }
111 );
112 }
113 );
114 //endregion
115
116
117 //region Language name parsing
118 describe("The language name parsing",
119 function () {
120 it("should use the last language as the main language if no lang uage is specified",
121 function () {
122 assert.deepEqual(
123 TestCase.parseLanguageNames("a"),
124 {
125 languages: ["a"],
126 mainLanguage: "a"
127 }
128 );
129
130 assert.deepEqual(
131 TestCase.parseLanguageNames("a+b+c"),
132 {
133 languages: ["a", "b", "c"],
134 mainLanguage: "c"
135 }
136 );
137 }
138 );
139
140
141 it("should use the specified language as main language",
142 function () {
143 assert.deepEqual(
144 TestCase.parseLanguageNames("a+b!+c"),
145 {
146 languages: ["a", "b", "c"],
147 mainLanguage: "b"
148 }
149 );
150 }
151 );
152
153
154 it("should throw an error if there are multiple main languages",
155 function () {
156 assert.throw(
157 function () {
158 TestCase.parseLanguageNames("a+b !+c!");
159 },
160 "There are multiple main languages defin ed."
161 );
162 }
163 );
164 }
165 );
166 //endregion
OLDNEW
« no previous file with comments | « lib/src/prism/tests/run.js ('k') | lib/src/prism/themes/prism.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698