mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-23 04:49:15 +08:00
Fix ace tests (#13734)
They formerly did not run because the `/// <reference>`s for tests were not placed at the top of the file, so they were regular comments.
This commit is contained in:
@@ -1,26 +0,0 @@
|
||||
|
||||
|
||||
var exports: any;
|
||||
var assert: any;
|
||||
var MockRenderer: any = null;
|
||||
var JavaScriptMode: any = null;
|
||||
|
||||
/// <reference path="tests/ace-default-tests.ts" />
|
||||
/// <reference path="tests/ace-background_tokenizer-tests.ts" />
|
||||
/// <reference path="tests/ace-document-tests.ts" />
|
||||
/// <reference path="tests/ace-edit_session-tests.ts" />
|
||||
/// <reference path="tests/ace-editor1-tests.ts" />
|
||||
/// <reference path="tests/ace-editor_highlight_selected_word-tests.ts" />
|
||||
/// <reference path="tests/ace-editor_navigation-tests.ts" />
|
||||
/// <reference path="tests/ace-editor_text_edit-tests.ts" />
|
||||
/// <reference path="tests/ace-multi_select-tests.ts" />
|
||||
/// <reference path="tests/ace-placeholder-tests.ts" />
|
||||
/// <reference path="tests/ace-range_list-tests.ts" />
|
||||
/// <reference path="tests/ace-range-tests.ts" />
|
||||
/// <reference path="tests/ace-search-tests.ts" />
|
||||
/// <reference path="tests/ace-selection-tests.ts" />
|
||||
/// <reference path="tests/ace-token_iterator-tests.ts" />
|
||||
/// <reference path="tests/ace-virtual_renderer-tests.ts" />
|
||||
|
||||
|
||||
|
||||
@@ -1,132 +1,129 @@
|
||||
|
||||
|
||||
var assert: any;
|
||||
var exports = {
|
||||
const aceAnchorTests = {
|
||||
|
||||
"test create anchor" : function() {
|
||||
var doc = new AceAjax.Document("juhu");
|
||||
var anchor = new AceAjax.Anchor(doc, 0, 0);
|
||||
|
||||
|
||||
assert.position(anchor.getPosition(), 0, 0);
|
||||
assert.equal(anchor.getDocument(), doc);
|
||||
},
|
||||
|
||||
|
||||
"test insert text in same row before cursor should move anchor column": function() {
|
||||
var doc = new AceAjax.Document("juhu\nkinners");
|
||||
var anchor = new AceAjax.Anchor(doc, 1, 4);
|
||||
|
||||
|
||||
doc.insert({row: 1, column: 1}, "123");
|
||||
assert.position(anchor.getPosition(), 1, 7);
|
||||
},
|
||||
|
||||
|
||||
"test insert lines before cursor should move anchor row": function() {
|
||||
var doc = new AceAjax.Document("juhu\nkinners");
|
||||
var anchor = new AceAjax.Anchor(doc, 1, 4);
|
||||
|
||||
|
||||
doc.insertLines(1, ["123", "456"]);
|
||||
assert.position(anchor.getPosition(), 3, 4);
|
||||
assert.position(anchor.getPosition(), 3, 4);
|
||||
},
|
||||
|
||||
|
||||
"test insert new line before cursor should move anchor column": function() {
|
||||
var doc = new AceAjax.Document("juhu\nkinners");
|
||||
var anchor = new AceAjax.Anchor(doc, 1, 4);
|
||||
|
||||
|
||||
doc.insertNewLine({row: 0, column: 0});
|
||||
assert.position(anchor.getPosition(), 2, 4);
|
||||
assert.position(anchor.getPosition(), 2, 4);
|
||||
},
|
||||
|
||||
|
||||
"test insert new line in anchor line before anchor should move anchor column and row": function() {
|
||||
var doc = new AceAjax.Document("juhu\nkinners");
|
||||
var anchor = new AceAjax.Anchor(doc, 1, 4);
|
||||
|
||||
|
||||
doc.insertNewLine({row: 1, column: 2});
|
||||
assert.position(anchor.getPosition(), 2, 2);
|
||||
},
|
||||
|
||||
|
||||
"test delete text in anchor line before anchor should move anchor column": function() {
|
||||
var doc = new AceAjax.Document("juhu\nkinners");
|
||||
var anchor = new AceAjax.Anchor(doc, 1, 4);
|
||||
|
||||
|
||||
doc.remove(new AceAjax.Range(1, 1, 1, 3));
|
||||
assert.position(anchor.getPosition(), 1, 2);
|
||||
},
|
||||
|
||||
|
||||
"test remove range which contains the anchor should move the anchor to the start of the range": function() {
|
||||
var doc = new AceAjax.Document("juhu\nkinners");
|
||||
var anchor = new AceAjax.Anchor(doc, 0, 3);
|
||||
|
||||
|
||||
doc.remove(new AceAjax.Range(0, 1, 1, 3));
|
||||
assert.position(anchor.getPosition(), 0, 1);
|
||||
},
|
||||
|
||||
|
||||
"test delete character before the anchor should have no effect": function() {
|
||||
var doc = new AceAjax.Document("juhu\nkinners");
|
||||
var anchor = new AceAjax.Anchor(doc, 1, 4);
|
||||
|
||||
|
||||
doc.remove(new AceAjax.Range(1, 4, 1, 5));
|
||||
assert.position(anchor.getPosition(), 1, 4);
|
||||
},
|
||||
|
||||
|
||||
"test delete lines in anchor line before anchor should move anchor row": function() {
|
||||
var doc = new AceAjax.Document("juhu\n1\n2\nkinners");
|
||||
var anchor = new AceAjax.Anchor(doc, 3, 4);
|
||||
|
||||
|
||||
doc.removeLines(1, 2);
|
||||
assert.position(anchor.getPosition(), 1, 4);
|
||||
},
|
||||
|
||||
|
||||
"test remove new line before the cursor": function() {
|
||||
var doc = new AceAjax.Document("juhu\nkinners");
|
||||
var anchor = new AceAjax.Anchor(doc, 1, 4);
|
||||
|
||||
|
||||
doc.removeNewLine(0);
|
||||
assert.position(anchor.getPosition(), 0, 8);
|
||||
},
|
||||
|
||||
|
||||
"test delete range which contains the anchor should move anchor to the end of the range": function() {
|
||||
var doc = new AceAjax.Document("juhu\nkinners");
|
||||
var anchor = new AceAjax.Anchor(doc, 1, 4);
|
||||
|
||||
|
||||
doc.remove(new AceAjax.Range(0, 2, 1, 2));
|
||||
assert.position(anchor.getPosition(), 0, 4);
|
||||
},
|
||||
|
||||
|
||||
"test delete line which contains the anchor should move anchor to the end of the range": function() {
|
||||
var doc = new AceAjax.Document("juhu\nkinners\n123");
|
||||
var anchor = new AceAjax.Anchor(doc, 1, 5);
|
||||
|
||||
|
||||
doc.removeLines(1, 1);
|
||||
assert.position(anchor.getPosition(), 1, 0);
|
||||
},
|
||||
|
||||
|
||||
"test remove after the anchor should have no effect": function() {
|
||||
var doc = new AceAjax.Document("juhu\nkinners\n123");
|
||||
var anchor = new AceAjax.Anchor(doc, 1, 2);
|
||||
|
||||
|
||||
doc.remove(new AceAjax.Range(1, 4, 2, 2));
|
||||
assert.position(anchor.getPosition(), 1, 2);
|
||||
},
|
||||
|
||||
|
||||
"test anchor changes triggered by document changes should emit change event": function(next) {
|
||||
var doc = new AceAjax.Document("juhu\nkinners\n123");
|
||||
var anchor = new AceAjax.Anchor(doc, 1, 5);
|
||||
|
||||
|
||||
anchor.on("change", function(e) {
|
||||
assert.position(anchor.getPosition(), 0, 0);
|
||||
next();
|
||||
});
|
||||
|
||||
|
||||
doc.remove(new AceAjax.Range(0, 0, 2, 1));
|
||||
},
|
||||
|
||||
|
||||
"test only fire change event if position changes": function() {
|
||||
var doc = new AceAjax.Document("juhu\nkinners\n123");
|
||||
var anchor = new AceAjax.Anchor(doc, 1, 5);
|
||||
|
||||
|
||||
anchor.on("change", function(e) {
|
||||
assert.fail();
|
||||
});
|
||||
|
||||
|
||||
doc.remove(new AceAjax.Range(2, 0, 2, 1));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
|
||||
|
||||
var assert: any;
|
||||
|
||||
function forceTokenize(session) {
|
||||
for (var i = 0, l = session.getLength(); i < l; i++)
|
||||
session.getTokens(i)
|
||||
@@ -13,7 +9,7 @@ function testStates(session, states) {
|
||||
assert.ok(l == states.length)
|
||||
}
|
||||
|
||||
var exports = {
|
||||
const aceBackgroundTokenizerTests = {
|
||||
|
||||
"test background tokenizer update on session change": function() {
|
||||
var doc = new AceAjax.EditSession([
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
|
||||
|
||||
var assert: any;
|
||||
var editor = ace.edit("editor");
|
||||
editor.setTheme("ace/theme/monokai");
|
||||
editor.getSession().setMode("ace/mode/javascript");
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
|
||||
|
||||
var assert: any;
|
||||
var exports = {
|
||||
const aceDocumentTests = {
|
||||
"test: insert text in line": function() {
|
||||
var doc = new AceAjax.Document(["12", "34"]);
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
|
||||
|
||||
var lang: any;
|
||||
var assert: any;
|
||||
|
||||
function createFoldTestSession() {
|
||||
var lines = [
|
||||
@@ -27,7 +26,7 @@ function assertArray(a, b) {
|
||||
}
|
||||
}
|
||||
|
||||
var exports = {
|
||||
const aceEditSessionTests = {
|
||||
|
||||
"test: find matching opening bracket in Text mode": function() {
|
||||
var session = new AceAjax.EditSession(["(()(", "())))"]);
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
|
||||
|
||||
var assert: any;
|
||||
var exports = {
|
||||
const aceEditor1Tests = {
|
||||
|
||||
setUp: function(next) {
|
||||
this.session1 = new AceAjax.EditSession(["abc", "def"]);
|
||||
|
||||
@@ -30,7 +30,7 @@ function callHighlighterUpdate(session: AceAjax.IEditSession, firstRow: number,
|
||||
var assert: any;
|
||||
var renderer: AceAjax.VirtualRenderer;
|
||||
|
||||
var exports = {
|
||||
const aceEditorHighlighSelectedWorkTests = {
|
||||
setUp: function(next) {
|
||||
var session = new AceAjax.EditSession(lipsum);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
|
||||
|
||||
var assert: any;
|
||||
var renderer: AceAjax.VirtualRenderer;
|
||||
var exports = {
|
||||
const aceEditorNavigationTests = {
|
||||
createEditSession: function (rows, cols) {
|
||||
var line = new Array(cols + 1).join("a");
|
||||
var text = new Array(rows).join(line + "\n") + line;
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
|
||||
|
||||
var assert: any;
|
||||
var renderer: AceAjax.VirtualRenderer;
|
||||
var mode: any;
|
||||
var exports = {
|
||||
const aceEditorTextEditTests = {
|
||||
"test: delete line from the middle": function () {
|
||||
var session = new AceAjax.EditSession(["a", "b", "c", "d"].join("\n"));
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
@@ -1,8 +1,3 @@
|
||||
|
||||
|
||||
var assert: any;
|
||||
var editor: any;
|
||||
var renderer: any;
|
||||
var exec = function (name?, times?, args?) {
|
||||
do {
|
||||
editor.commands.exec(name, editor, args);
|
||||
@@ -12,7 +7,7 @@ var testRanges = function (str) {
|
||||
assert.equal(editor.selection.getAllRanges() + "", str + "");
|
||||
}
|
||||
|
||||
var exports = {
|
||||
const aceMultiSelectTests = {
|
||||
|
||||
name: "ACE multi_select.js",
|
||||
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
|
||||
|
||||
var assert: any;
|
||||
var renderer: AceAjax.VirtualRenderer;
|
||||
var mode: any;
|
||||
var exports = {
|
||||
const acePlaceholderTests = {
|
||||
|
||||
"test: simple at the end appending of text": function () {
|
||||
var session = new AceAjax.EditSession("var a = 10;\nconsole.log(a, a);", mode);
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
|
||||
|
||||
var assert: any;
|
||||
var exports = {
|
||||
const aceRangeTests = {
|
||||
|
||||
name: "ACE range.js",
|
||||
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
|
||||
|
||||
var assert: any;
|
||||
function flatten(rangeList) {
|
||||
var points = [];
|
||||
rangeList.ranges.forEach(function (r) {
|
||||
@@ -12,7 +9,7 @@ function testRangeList(rangeList, points) {
|
||||
assert.equal("" + flatten(rangeList), "" + points);
|
||||
}
|
||||
|
||||
var exports = {
|
||||
const aceRangeListTests = {
|
||||
|
||||
name: "ACE range_list.js",
|
||||
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
|
||||
|
||||
var assert: any;
|
||||
var exports = {
|
||||
const aceSearchTests = {
|
||||
"test: configure the search object": function () {
|
||||
var search = new AceAjax.Search();
|
||||
search.set({
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
|
||||
|
||||
var assert: any;
|
||||
var exports = {
|
||||
const aceSelectionTests = {
|
||||
createSession: function (rows, cols) {
|
||||
var line = new Array(cols + 1).join("a");
|
||||
var text = new Array(rows).join(line + "\n") + line;
|
||||
@@ -126,7 +123,7 @@ var exports = {
|
||||
},
|
||||
|
||||
"test: moveCursor word left with umlauts": function () {
|
||||
var session = new AceAjax.EditSession(" Fu<46> F<><46>e");
|
||||
var session = new AceAjax.EditSession(" Fu<46> F<><46>e");
|
||||
|
||||
var selection = session.getSelection();
|
||||
selection.moveCursorTo(0, 9)
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
|
||||
|
||||
var assert: any;
|
||||
var mode: any;
|
||||
var exports = {
|
||||
const aceTokenIteratorTests = {
|
||||
"test: token iterator initialization in JavaScript document": function () {
|
||||
var lines = [
|
||||
"function foo(items) {",
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
|
||||
|
||||
var assert: any;
|
||||
var exports = {
|
||||
const aceVirtualRendererTests = {
|
||||
"test: screen2text the column should be rounded to the next character edge": function () {
|
||||
var el = document.createElement("div");
|
||||
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
{
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"all-tests.ts"
|
||||
],
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"noImplicitAny": false,
|
||||
"noImplicitThis": false,
|
||||
"strictNullChecks": false,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
@@ -16,5 +12,25 @@
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"tests/ace-anchor-tests.ts",
|
||||
"tests/ace-background_tokenizer-tests.ts",
|
||||
"tests/ace-default-tests.ts",
|
||||
"tests/ace-document-tests.ts",
|
||||
"tests/ace-edit_session-tests.ts",
|
||||
"tests/ace-editor1-tests.ts",
|
||||
"tests/ace-editor_highlight_selected_word-tests.ts",
|
||||
"tests/ace-editor_navigation-tests.ts",
|
||||
"tests/ace-editor_text_edit-tests.ts",
|
||||
"tests/ace-multi_select-tests.ts",
|
||||
"tests/ace-placeholder-tests.ts",
|
||||
"tests/ace-range-tests.ts",
|
||||
"tests/ace-range_list-tests.ts",
|
||||
"tests/ace-search-tests.ts",
|
||||
"tests/ace-selection-tests.ts",
|
||||
"tests/ace-token_iterator-tests.ts",
|
||||
"tests/ace-virtual_renderer-tests.ts"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user