mirror of
https://github.com/RustyRaptor/brackets.git
synced 2026-12-04 00:15:22 -07:00
add new test cases
This commit is contained in:
1 parent
04032a1822
commit
fbf2437740
2 files changed
+341
-6
No files matched your search
@@ -47,3 +47,99 @@ var x = A1;
|
||||
var arr = [];
|
||||
arr["my-key"] = 1;
|
||||
arr["for"] = 10;
|
||||
|
||||
function MClass() {
|
||||
"use strict";
|
||||
}
|
||||
MClass.prototype.calc = function (a4, b4) {
|
||||
"use strict";
|
||||
return a4 + b4;
|
||||
};
|
||||
|
||||
var ins1 = new MClass();
|
||||
ins1.calc(10, 10);
|
||||
|
||||
var Person = function (name) {
|
||||
"use strict";
|
||||
this.name = name;
|
||||
};
|
||||
|
||||
Person.prototype.getName = function () {
|
||||
"use strict";
|
||||
return this.name;
|
||||
};
|
||||
|
||||
var Customer = function (name) {
|
||||
"use strict";
|
||||
this.name = name;
|
||||
};
|
||||
|
||||
Customer.prototype = new Person();
|
||||
|
||||
var myCustomer = new Customer('Dream Inc.');
|
||||
myCustomer.getName();
|
||||
|
||||
Customer.prototype.setAmountDue = function (amountDue) {
|
||||
"use strict";
|
||||
this.amountDue = amountDue;
|
||||
};
|
||||
Customer.prototype.getAmountDue = function () {
|
||||
"use strict";
|
||||
return this.amountDue;
|
||||
};
|
||||
|
||||
function testInnerFunc() {
|
||||
"use strict";
|
||||
var t = "test";
|
||||
function innerFunc(arg) {
|
||||
return {t: function () {return arg; }};
|
||||
}
|
||||
var t2 = innerFunc("test").t().toLocaleLowerCase();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {boolean} a
|
||||
* @param {Date} b
|
||||
*/
|
||||
|
||||
function funTypeAn1(a, b) {
|
||||
"use strict";
|
||||
return {x: a, y: b};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {function(): number} f
|
||||
*/
|
||||
function funFuncArg(f) {
|
||||
"use strict";
|
||||
return f();
|
||||
}
|
||||
|
||||
function testRef1() {
|
||||
"use strict";
|
||||
return 100;
|
||||
}
|
||||
|
||||
funFuncArg(testRef1); //also test return type
|
||||
|
||||
/**
|
||||
* @param {function(string,number): string} f
|
||||
*/
|
||||
function funFunc2Arg(f) {
|
||||
"use strict";
|
||||
var s = "test";
|
||||
return f(s, 10);
|
||||
}
|
||||
|
||||
function testRef2(s, n) {
|
||||
"use strict";
|
||||
return s + n;
|
||||
}
|
||||
|
||||
funFunc2Arg(testRef2);
|
||||
|
||||
var funArr = [];
|
||||
funArr.index1 = testRef1;
|
||||
funArr.index2 = testRef2;
|
||||
|
||||
@@ -713,21 +713,188 @@ define(function (require, exports, module) {
|
||||
});
|
||||
});
|
||||
|
||||
it("should jump to function", function () {
|
||||
var start = { line: 43, ch: 0 };
|
||||
it("should list later defined property names", function () {
|
||||
var start = { line: 17, ch: 11 };
|
||||
|
||||
testEditor.setCursorPos(start);
|
||||
var hintObj = expectHints(JSCodeHints.jsHintProvider);
|
||||
runs(function () {
|
||||
editorJumped({line: 7, ch: 13});
|
||||
hintsPresentExact(hintObj, ["foo", "propB"]);
|
||||
});
|
||||
});
|
||||
|
||||
it("should list matching property names", function () {
|
||||
var start = { line: 12, ch: 10 };
|
||||
|
||||
testDoc.replaceRange("param", start, start);
|
||||
testEditor.setCursorPos(start);
|
||||
var hintObj = expectHints(JSCodeHints.jsHintProvider);
|
||||
runs(function () {
|
||||
hintsPresentExact(hintObj, ["paramB1", "paramB2"]);
|
||||
});
|
||||
});
|
||||
|
||||
it("should take anotation parameter type:String", function () {
|
||||
var start = { line: 37, ch: 21 };
|
||||
|
||||
testDoc.replaceRange("var k= funD(10,11).x.", start, start);
|
||||
testEditor.setCursorPos(start);
|
||||
var hintObj = expectHints(JSCodeHints.jsHintProvider);
|
||||
runs(function () {
|
||||
hintsPresentOrdered(hintObj, ["charAt", "charCodeAt", "concat", "indexOf"]);
|
||||
});
|
||||
});
|
||||
|
||||
it("should jump to var", function () {
|
||||
var start = { line: 44, ch: 10 };
|
||||
it("should take anotation parameter type:Number", function () {
|
||||
var start = { line: 37, ch: 21 };
|
||||
|
||||
testDoc.replaceRange("var k= funD(10,11).y.", start, start);
|
||||
testEditor.setCursorPos(start);
|
||||
var hintObj = expectHints(JSCodeHints.jsHintProvider);
|
||||
runs(function () {
|
||||
hintsPresentOrdered(hintObj, ["toExponential", "toFixed", "toString"]);
|
||||
});
|
||||
});
|
||||
|
||||
it("should add new method on String .prototype", function () {
|
||||
var start = { line: 37, ch: 0 };
|
||||
var testPos = { line: 40, ch: 12 };
|
||||
testDoc.replaceRange("String.prototype.times = function (count) {\n" + "\treturn count < 1 ? '' : new Array[count + 1].join(this);\n};\n\"hello\".time", start, start);
|
||||
testEditor.setCursorPos(testPos);
|
||||
var hintObj = expectHints(JSCodeHints.jsHintProvider);
|
||||
runs(function () {
|
||||
hintsPresentOrdered(hintObj, ["times", "trimLeft"]);
|
||||
});
|
||||
});
|
||||
|
||||
it("should list function defined from .prototype", function () {
|
||||
var start = { line: 59, ch: 5 };
|
||||
|
||||
testEditor.setCursorPos(start);
|
||||
var hintObj = expectHints(JSCodeHints.jsHintProvider);
|
||||
runs(function () {
|
||||
editorJumped({line: 3, ch: 6});
|
||||
hintsPresentExact(hintObj, ["calc"]);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
it("should list function type defined from .prototype", function () {
|
||||
var start = { line: 59, ch: 10 };
|
||||
testEditor.setCursorPos(start);
|
||||
var hintObj = expectHints(JSCodeHints.jsHintProvider);
|
||||
runs(function () {
|
||||
hintsPresentExact(hintObj, ["calc(a4: number, b4: number) -> number"]);
|
||||
});
|
||||
});
|
||||
|
||||
it("should list function inhertated from super class", function () {
|
||||
var start = { line: 79, ch: 11 };
|
||||
testEditor.setCursorPos(start);
|
||||
var hintObj = expectHints(JSCodeHints.jsHintProvider);
|
||||
runs(function () {
|
||||
hintsPresentExact(hintObj, ["getAmountDue", "getName", "name", "setAmountDue"]);
|
||||
});
|
||||
});
|
||||
|
||||
it("should show argument from from .prototype.Method", function () {
|
||||
var start = { line: 80, ch: 0 },
|
||||
testPos = { line: 80, ch: 24 };
|
||||
|
||||
testDoc.replaceRange("myCustomer.setAmountDue(", start);
|
||||
testEditor.setCursorPos(testPos);
|
||||
var hintObj = expectHints(JSCodeHints.jsHintProvider);
|
||||
runs(function () {
|
||||
hintsPresentOrdered(hintObj, ["setAmountDue(amountDue: ?)"]);
|
||||
});
|
||||
});
|
||||
|
||||
it("should show guessed argument type from current passing parameter", function () {
|
||||
var start = { line: 80, ch: 0 },
|
||||
testPos = { line: 80, ch: 24 };
|
||||
|
||||
testDoc.replaceRange("myCustomer.setAmountDue(10)", start);
|
||||
testEditor.setCursorPos(testPos);
|
||||
var hintObj = expectHints(JSCodeHints.jsHintProvider);
|
||||
runs(function () {
|
||||
hintsPresentOrdered(hintObj, ["setAmountDue(amountDue: number)"]);
|
||||
});
|
||||
});
|
||||
|
||||
it("should show inner function type", function () {
|
||||
var testPos = { line: 96, ch: 23 };
|
||||
|
||||
testEditor.setCursorPos(testPos);
|
||||
var hintObj = expectHints(JSCodeHints.jsHintProvider);
|
||||
runs(function () {
|
||||
hintsPresentOrdered(hintObj, ["innerFunc(arg: string) -> {t}"]);
|
||||
});
|
||||
});
|
||||
|
||||
it("should show type for inner function returned function", function () {
|
||||
var testPos = { line: 96, ch: 33 };
|
||||
|
||||
testEditor.setCursorPos(testPos);
|
||||
var hintObj = expectHints(JSCodeHints.jsHintProvider);
|
||||
runs(function () {
|
||||
hintsPresentOrdered(hintObj, ["t() -> string"]);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// parameter type anotation tests, due to another bug #3670: first argument has ?
|
||||
xit("should list parameter Date,boolean type", function () {
|
||||
var start = { line: 109, ch: 0 },
|
||||
testPos = { line: 109, ch: 11 };
|
||||
|
||||
testDoc.replaceRange("funTypeAn1(", start);
|
||||
testEditor.setCursorPos(testPos);
|
||||
var hintObj = expectHints(JSCodeHints.jsHintProvider);
|
||||
runs(function () {
|
||||
hintsPresentExact(hintObj, ["funTypeAn1((a: bool, b: Date) -> {x, y}"]);
|
||||
});
|
||||
});
|
||||
|
||||
// parameter type anotation tests, due to another bug #3670: first argument has ?
|
||||
xit("should list parameter function type and best guess for its argument/return types", function () {
|
||||
var testPos = { line: 123, ch: 11 };
|
||||
|
||||
testEditor.setCursorPos(testPos);
|
||||
var hintObj = expectHints(JSCodeHints.jsHintProvider);
|
||||
runs(function () {
|
||||
hintsPresentExact(hintObj, ["funFuncArg(f: fn() -> number) -> number"]);
|
||||
});
|
||||
});
|
||||
|
||||
// parameter type anotation tests
|
||||
it("should list parameter function type and best guess for function call/return types", function () {
|
||||
var testPos = { line: 139, ch: 12 };
|
||||
|
||||
testEditor.setCursorPos(testPos);
|
||||
var hintObj = expectHints(JSCodeHints.jsHintProvider);
|
||||
runs(function () {
|
||||
hintsPresentExact(hintObj, ["funFunc2Arg(f: fn(s: string, n: number) -> string) -> string"]);
|
||||
});
|
||||
});
|
||||
|
||||
it("should list array containing functions", function () {
|
||||
var testPos = { line: 142, ch: 7 };
|
||||
|
||||
testEditor.setCursorPos(testPos);
|
||||
var hintObj = expectHints(JSCodeHints.jsHintProvider);
|
||||
runs(function () {
|
||||
hintsPresent(hintObj, ["index1", "index2"]);
|
||||
});
|
||||
});
|
||||
|
||||
it("should list function reference", function () {
|
||||
var start = { line: 144, ch: 0 },
|
||||
testPos = { line: 144, ch: 14 };
|
||||
|
||||
testDoc.replaceRange("funArr.index1(", start);
|
||||
testEditor.setCursorPos(testPos);
|
||||
var hintObj = expectHints(JSCodeHints.jsHintProvider);
|
||||
runs(function () {
|
||||
hintsPresentExact(hintObj, ["index1() -> number"]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -778,6 +945,78 @@ define(function (require, exports, module) {
|
||||
expect(testDoc.getLine(end.line).length).toEqual(7);
|
||||
});
|
||||
});
|
||||
|
||||
it("should jump to function", function () {
|
||||
var start = { line: 43, ch: 0 };
|
||||
|
||||
testEditor.setCursorPos(start);
|
||||
runs(function () {
|
||||
editorJumped({line: 7, ch: 13});
|
||||
});
|
||||
});
|
||||
|
||||
it("should jump to var", function () {
|
||||
var start = { line: 44, ch: 10 };
|
||||
|
||||
testEditor.setCursorPos(start);
|
||||
runs(function () {
|
||||
editorJumped({line: 3, ch: 6});
|
||||
});
|
||||
});
|
||||
it("should jump to closure, early defined var", function () {
|
||||
var start = { line: 17, ch: 9 };
|
||||
|
||||
testEditor.setCursorPos(start);
|
||||
runs(function () {
|
||||
editorJumped({line: 10, ch: 10});
|
||||
});
|
||||
});
|
||||
|
||||
// bug: the issue: timeout due to file.open command not found
|
||||
xit("should jump to the definition in new module file", function () {
|
||||
var start = { line: 38, ch: 21 };
|
||||
|
||||
testEditor.setCursorPos(start);
|
||||
runs(function () {
|
||||
editorJumped({line: 4, ch: 34}); //jump to another file
|
||||
});
|
||||
});
|
||||
|
||||
it("should jump to the method definition in .prototype", function () {
|
||||
var start = { line: 59, ch: 8 };
|
||||
|
||||
testEditor.setCursorPos(start);
|
||||
runs(function () {
|
||||
editorJumped({line: 56, ch: 1}); //jump to prototype.calc
|
||||
});
|
||||
});
|
||||
|
||||
it("should jump to parameter passed in the method", function () {
|
||||
var start = { line: 63, ch: 20 };
|
||||
|
||||
testEditor.setCursorPos(start);
|
||||
runs(function () {
|
||||
editorJumped({line: 61, ch: 27});
|
||||
});
|
||||
});
|
||||
|
||||
it("should jump to parameter passed in anonymous method", function () {
|
||||
var start = { line: 83, ch: 25 };
|
||||
|
||||
testEditor.setCursorPos(start);
|
||||
runs(function () {
|
||||
editorJumped({line: 81, ch: 53});
|
||||
});
|
||||
});
|
||||
|
||||
it("should jump to inner method", function () {
|
||||
var start = { line: 96, ch: 32 };
|
||||
|
||||
testEditor.setCursorPos(start);
|
||||
runs(function () {
|
||||
editorJumped({line: 94, ch: 45});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user