| <html> |
| <head> |
| <script src="../../http/tests/inspector/inspector-test.js"></script> |
| <script src="editor-test.js"></script> |
| <script> |
| |
| function test() |
| { |
| function bar() { |
| // comment here |
| var a, b, c, d; |
| var a = ((1 + 2) * (3 + 4)); |
| for(var i = 0; i < 100; ++i) { |
| if (a < b && c > d) { |
| } |
| } |
| } |
| |
| |
| var textEditor = InspectorTest.createTestEditor(); |
| textEditor.overrideViewportForTest(0, undefined, 3); |
| textEditor.mimeType = "text/javascript"; |
| textEditor.setReadOnly(false); |
| textEditor.setText(bar.toString()); |
| InspectorTest.addResult(textEditor.text()); |
| |
| var braceHighlighter = new WebInspector.TextEditorModel.BraceMatcher(textEditor._textModel); |
| function testAndDump(lineNumber, column) |
| { |
| var line = textEditor._textModel.line(lineNumber); |
| var text = "Cursor at line #" + (lineNumber) + " >>>" + line + "<<< column " + column + " (char is \"" + line.charAt(column) + "\")"; |
| text += "\nenclosing braces: " + JSON.stringify(braceHighlighter.enclosingBraces(lineNumber, column)); |
| text += "\n"; |
| InspectorTest.addResult(text); |
| } |
| |
| testAndDump(0, 0); |
| testAndDump(0, 12); |
| testAndDump(0, 13); |
| testAndDump(0, 14); |
| testAndDump(0, 15); |
| testAndDump(2, 5); |
| testAndDump(3, 12); |
| testAndDump(3, 13); |
| testAndDump(3, 14); |
| testAndDump(3, 15); |
| testAndDump(3, 22); |
| testAndDump(3, 24); |
| testAndDump(3, 29); |
| testAndDump(3, 30); |
| testAndDump(3, 31); |
| testAndDump(4, 19); |
| testAndDump(4, 32); |
| testAndDump(4, 33); |
| testAndDump(5, 20); |
| testAndDump(5, 28); |
| testAndDump(6, 8); |
| testAndDump(7, 4); |
| testAndDump(8, 0); |
| |
| InspectorTest.completeTest(); |
| } |
| |
| </script> |
| </head> |
| |
| <body onload="runTest()"> |
| <p> |
| This test checks highlighter correctness. |
| </p> |
| |
| </body> |
| </html> |