-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(shacl-js): rewrite JS tests using ECMAScript >= 6
- Loading branch information
1 parent
34ae927
commit 359e7a5
Showing
6 changed files
with
38 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
function maxLength($value, $maxLength) { | ||
return ($value.lex.length <= $maxLength.lex) | ||
return ($value.lex.length <= $maxLength.lex) | ||
} |
12 changes: 6 additions & 6 deletions
12
src/test/resources/js/tests/component/propertyShapeComponent.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
function propertyShape($this, $path, $minCardinality) { | ||
var it = $data.find($this, $path, null); | ||
var count = 0; | ||
for(var t = it.next(); t; t = it.next()) { | ||
count++; | ||
} | ||
return count >= $minCardinality.lex; | ||
let it = $data.find($this, $path, null); | ||
let count = 0; | ||
for (let t = it.next(); t; t = it.next()) { | ||
count++; | ||
} | ||
return count >= $minCardinality.lex; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
function booleanFunction() { | ||
return true; | ||
return true; | ||
} | ||
|
||
function floatFunction() { | ||
return 4.2; | ||
return 4.2; | ||
} | ||
|
||
function integerFunction() { | ||
return 42; | ||
return 42; | ||
} | ||
|
||
function nodeFunction() { | ||
return TermFactory.namedNode("http://aldi.de"); | ||
return TermFactory.namedNode("http://aldi.de"); | ||
} | ||
|
||
function stringFunction() { | ||
return "Hello"; | ||
return "Hello"; | ||
} | ||
|
||
function withArguments($arg1, $arg2) { | ||
return TermFactory.namedNode("http://aldi.de/product_" + $arg1.value + "_" + $arg2.value); | ||
return TermFactory.namedNode("http://aldi.de/product_" + $arg1.value + "_" + $arg2.value); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
function germanLabel($value) { | ||
var results = []; | ||
var p = TermFactory.namedNode("http://example.org/ns#germanLabel"); | ||
var s = $data.find($value, p, null); | ||
for(var t = s.next(); t; t = s.next()) { | ||
var object = t.object; | ||
if(object.termType != "Literal" || !object.language.startsWith("de")) { | ||
results.push({ | ||
value : object | ||
}); | ||
} | ||
} | ||
return results; | ||
let results = []; | ||
let p = TermFactory.namedNode("http://example.org/ns#germanLabel"); | ||
let s = $data.find($value, p, null); | ||
for (let t = s.next(); t; t = s.next()) { | ||
let object = t.object; | ||
if (object.termType !== "Literal" || !object.language.startsWith("de")) { | ||
results.push({ | ||
value: object | ||
}); | ||
} | ||
} | ||
return results; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
function simple($value) { | ||
if(!$value.isURI()) { | ||
return "IRIs expected"; | ||
} | ||
if (!$value.isURI()) { | ||
return "IRIs expected"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
var NS = "http://datashapes.org/js/tests/rules/rectangle.test#"; | ||
const NS = "http://datashapes.org/js/tests/rules/rectangle.test#"; | ||
|
||
function computeArea($this) { | ||
var width = getProperty($this, "width"); | ||
var height = getProperty($this, "height"); | ||
var area = TermFactory.literal(width.lex * height.lex, width.datatype); | ||
var areaProperty = TermFactory.namedNode(NS + "area"); | ||
return [ [$this, areaProperty, area] ]; | ||
let width = getProperty($this, "width"); | ||
let height = getProperty($this, "height"); | ||
let area = TermFactory.literal(width.lex * height.lex, width.datatype); | ||
let areaProperty = TermFactory.namedNode(NS + "area"); | ||
return [ [$this, areaProperty, area] ]; | ||
} | ||
|
||
function getProperty($this, name) { | ||
var it = $data.find($this, TermFactory.namedNode(NS + name), null); | ||
var result = it.next().object; | ||
it.close(); | ||
return result; | ||
let it = $data.find($this, TermFactory.namedNode(NS + name), null); | ||
let result = it.next().object; | ||
it.close(); | ||
return result; | ||
} |