1 Verifies JavaScript pretty-printing functionality.
4 Running: forInFormatting
10 Correct mapping for <myMap>
11 Correct mapping for <print>
13 Running: forOfFormatting
15 for (var value of myMap)
19 Correct mapping for <myMap>
20 Correct mapping for <print>
22 Running: commaBetweenStatementsFormatting
26 hasNew ? refresh() : noop();
29 Correct mapping for <noop>
30 Correct mapping for <hasNew>
32 Running: complexScriptFormatting
39 function withComments()
42 return "functionWithComments";
46 onmessage = function(event) {
47 var source = event.data;
48 var formattedSource = beautify(source);
49 var mapping = buildMapping(source, formattedSource);
51 formattedSource: formattedSource,
56 function beautify(source) {
57 var ast = parse.parse(source);
65 return process.gen_code(ast, beautifyOptions)
67 function buildMapping(source, formattedSource) {
73 var regexp = /(^|[^\\])\b((?=\D)[\$\.\w]+)\b/g;
76 var match = regexp.exec(formattedSource);
79 var position = source.indexOf(match[2], lastPosition);
81 throw "No match found in original source for " + match[2];
82 mapping.original.push(position);
83 mapping.formatted.push(match.index + match[1].length);
84 lastPosition = position + match[2].length
92 importScripts("UglifyJS/parse-js.js");
95 importScripts("UglifyJS/process.js");
96 var process = exports;
105 Correct mapping for <function>
106 Correct mapping for <formatted1>
107 Correct mapping for <variable1>
108 Correct mapping for < return "functionWithComments">
109 Correct mapping for <onmessage>
110 Correct mapping for <indent_start>
111 Correct mapping for <function require>
112 Correct mapping for <var regexp>
113 Correct mapping for <importScripts>
114 Correct mapping for <formatted2>
116 Running: ifStatementIndentRegression
128 Correct mapping for <pretty>
129 Correct mapping for <reset>