aggregate the tests in library-tests/Util into a single .ql file

This commit is contained in:
Erik Krogh Kristensen
2020-10-20 13:38:24 +02:00
parent 90bb38b522
commit 036187cd70
9 changed files with 33 additions and 18 deletions

View File

@@ -1 +0,0 @@
| X | X | Xx | XX | Xx | XX |

View File

@@ -1,4 +0,0 @@
import semmle.javascript.Util
select capitalize("x"), capitalize("X"), capitalize("xx"), capitalize("XX"), capitalize("Xx"),
capitalize("xX")

View File

@@ -1,4 +0,0 @@
import semmle.javascript.Util
from Expr e
select e, describeExpression(e)

View File

@@ -1 +0,0 @@
| xs | x | xs | xs |

View File

@@ -1,3 +0,0 @@
import semmle.javascript.Util
select pluralize("x", 0), pluralize("x", 1), pluralize("x", 2), pluralize("x", -1)

View File

@@ -1,3 +1,11 @@
capitalize
| X | X |
| X | x |
| XX | XX |
| XX | xX |
| Xx | Xx |
| Xx | xx |
describeExpression
| tst.js:1:1:15:2 | (functi ... !'';\\n}) | expression |
| tst.js:1:2:15:1 | functio ... !'';\\n} | expression |
| tst.js:2:5:2:5 | v | use of variable 'v' |
@@ -34,3 +42,10 @@
| tst.js:13:7:13:9 | 'x' | expression |
| tst.js:14:5:14:7 | !'' | negation |
| tst.js:14:6:14:7 | '' | expression |
test_pluralize
| x | 1 |
| xs | 0 |
| xs | 2 |
| xs | -1 |
#select
| y | | X | XX | XXy |

View File

@@ -0,0 +1,18 @@
import javascript
query predicate capitalize(string cap, string s) {
s = ["x", "X", "xx", "XX", "Xx", "xX"] and
cap = capitalize(s)
}
query predicate describeExpression(Expr e, string description) {
description = describeExpression(e)
}
query predicate test_pluralize(string res, int num) {
num = [0, 1, 2, -1] and
res = pluralize("x", num)
}
select truncate("X", 0, "y"), truncate("", 2, "y"), truncate("X", 2, "y"), truncate("XX", 2, "y"),
truncate("XXX", 2, "y")

View File

@@ -1 +0,0 @@
| y | | X | XX | XXy |

View File

@@ -1,4 +0,0 @@
import semmle.javascript.Util
select truncate("X", 0, "y"), truncate("", 2, "y"), truncate("X", 2, "y"), truncate("XX", 2, "y"),
truncate("XXX", 2, "y")