JS: Add JSDoc test

This commit is contained in:
Asger F
2019-04-16 13:00:17 +01:00
parent 6b2b64cb2e
commit e295c3a224
3 changed files with 58 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
test_isString
| string |
test_isNumber
| number |
test_QualifiedName
| VarType | VarType |
| boolean | boolean |
| foo.bar.baz | foo.bar.baz |
| number | number |
| string | string |
test_ParameterType
| tst.js:7:12:7:12 | x | string |
| tst.js:7:15:7:15 | y | number? |
| tst.js:7:18:7:18 | z | foo.bar.baz |
test_VarType
| tst.js:7:12:7:12 | x | string |
| tst.js:7:15:7:15 | y | number? |
| tst.js:7:18:7:18 | z | foo.bar.baz |
| tst.js:11:7:11:7 | w | VarType |
test_ReturnType
| tst.js:7:1:12:1 | functio ... null;\\n} | boolean |

View File

@@ -0,0 +1,25 @@
import javascript
query TypeAnnotation test_isString() {
result.isString()
}
query TypeAnnotation test_isNumber() {
result.isNumber()
}
query TypeAnnotation test_QualifiedName(string name) {
result.hasQualifiedName(name)
}
query TypeAnnotation test_ParameterType(Parameter p) {
result = p.getTypeAnnotation()
}
query TypeAnnotation test_VarType(VarDecl decl) {
result = decl.getTypeAnnotation()
}
query TypeAnnotation test_ReturnType(Function f) {
result = f.getReturnTypeAnnotation()
}

View File

@@ -0,0 +1,12 @@
/**
* @param {string} x
* @param {number?} y
* @param {foo.bar.baz} z
* @returns {boolean}
*/
function f(x, y, z) {
/**
* @type {VarType}
*/
var w = null;
}