Skip to content

Commit

Permalink
Update official test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
leadpony committed Oct 31, 2020
1 parent b01000c commit c4c3538
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion JSON-Schema-Test-Suite
Submodule JSON-Schema-Test-Suite updated 58 files
+1 −0 README.md
+3 −1 bin/jsonschema_suite
+3 −1 index.js
+0 −0 remotes/baseUriChange/folderInteger.json
+3 −0 remotes/baseUriChangeFolder/folderInteger.json
+3 −0 remotes/baseUriChangeFolderInSubschema/folderInteger.json
+84 −0 tests/draft2019-09/const.json
+10 −0 tests/draft2019-09/enum.json
+30 −0 tests/draft2019-09/if-then-else.json
+11 −0 tests/draft2019-09/multipleOf.json
+0 −11 tests/draft2019-09/optional/ecmascript-regex.json
+13 −0 tests/draft2019-09/optional/float-overflow.json
+10 −0 tests/draft2019-09/optional/format/date-time.json
+10 −0 tests/draft2019-09/optional/format/date.json
+35 −0 tests/draft2019-09/optional/format/ipv6.json
+5 −0 tests/draft2019-09/optional/format/uri.json
+5 −5 tests/draft2019-09/refRemote.json
+15 −15 tests/draft2019-09/unevaluatedItems.json
+10 −0 tests/draft2019-09/uniqueItems.json
+10 −0 tests/draft3/optional/format/date-time.json
+15 −0 tests/draft3/optional/format/date.json
+8 −6 tests/draft3/ref.json
+1 −1 tests/draft3/refRemote.json
+10 −0 tests/draft3/uniqueItems.json
+10 −0 tests/draft4/enum.json
+11 −0 tests/draft4/multipleOf.json
+0 −11 tests/draft4/optional/ecmascript-regex.json
+13 −0 tests/draft4/optional/float-overflow.json
+10 −0 tests/draft4/optional/format/date-time.json
+35 −0 tests/draft4/optional/format/ipv6.json
+5 −0 tests/draft4/optional/format/uri.json
+8 −6 tests/draft4/ref.json
+3 −3 tests/draft4/refRemote.json
+10 −0 tests/draft4/uniqueItems.json
+84 −0 tests/draft6/const.json
+10 −0 tests/draft6/enum.json
+11 −0 tests/draft6/multipleOf.json
+0 −11 tests/draft6/optional/ecmascript-regex.json
+13 −0 tests/draft6/optional/float-overflow.json
+11 −1 tests/draft6/optional/format/date-time.json
+35 −0 tests/draft6/optional/format/ipv6.json
+5 −0 tests/draft6/optional/format/uri.json
+8 −6 tests/draft6/ref.json
+3 −3 tests/draft6/refRemote.json
+10 −0 tests/draft6/uniqueItems.json
+84 −0 tests/draft7/const.json
+10 −0 tests/draft7/enum.json
+30 −0 tests/draft7/if-then-else.json
+11 −0 tests/draft7/multipleOf.json
+0 −11 tests/draft7/optional/ecmascript-regex.json
+13 −0 tests/draft7/optional/float-overflow.json
+10 −0 tests/draft7/optional/format/date-time.json
+10 −0 tests/draft7/optional/format/date.json
+35 −0 tests/draft7/optional/format/ipv6.json
+5 −0 tests/draft7/optional/format/uri.json
+8 −6 tests/draft7/ref.json
+3 −3 tests/draft7/refRemote.json
+10 −0 tests/draft7/uniqueItems.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,10 @@ public static Stream<TestCase> mandatory() {
}

private static final String[] OPTIONAL = {
"optional/bignum.json",
// Draft-04 does not have the "regex" format.
"optional/bignum.json",
"optional/ecmascript-regex.json",
"optional/float-overflow.json",
"optional/non-bmp-regex.json",
"optional/zeroTerminatedFloats.json",

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,10 @@ public static Stream<TestCase> mandatory() {
}

private static final String[] OPTIONAL = {
"optional/bignum.json",
// Draft-06 does not have the "regex" format.
"optional/bignum.json",
"optional/ecmascript-regex.json",
"optional/float-overflow.json",
"optional/non-bmp-regex.json",

"optional/format/date-time.json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public static Stream<TestCase> mandatory() {
"optional/bignum.json",
"optional/content.json",
"optional/ecmascript-regex.json",
"optional/float-overflow.json",
"optional/non-bmp-regex.json",

"optional/format/date.json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public static Stream<TestCase> mandatory() {
"optional/bignum.json",
"optional/content.json",
"optional/ecmascript-regex.json",
"optional/float-overflow.json",
"optional/non-bmp-regex.json",
"optional/refOfUnknownKeyword.json",

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@
*/
package org.leadpony.justify.internal.keyword.validation;

import java.math.BigDecimal;
import java.util.Set;

import jakarta.json.JsonValue;
import jakarta.json.stream.JsonParser;

import org.leadpony.justify.api.EvaluatorContext;
import org.leadpony.justify.api.InstanceType;
import org.leadpony.justify.api.SpecVersion;
Expand Down Expand Up @@ -47,10 +50,17 @@ protected Keyword map(JsonValue jsonValue, Set<InstanceType> types) {
};

private static InstanceType getNarrowType(InstanceType type, EvaluatorContext context) {
if (type == InstanceType.NUMBER
&& context.getParser().isIntegralNumber()) {
if (type != InstanceType.NUMBER) {
return type;
}
JsonParser parser = context.getParser();
if (parser.isIntegralNumber()) {
return InstanceType.INTEGER;
} else {
BigDecimal value = parser.getBigDecimal();
if (value.scale() <= 0) {
return InstanceType.INTEGER;
}
return type;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ protected InstanceType toNarrowType(InstanceType type, EvaluatorContext context)
return InstanceType.INTEGER;
} else {
BigDecimal value = parser.getBigDecimal().stripTrailingZeros();
if (value.scale() == 0) {
if (value.scale() <= 0) {
return InstanceType.INTEGER;
}
return type;
Expand Down

0 comments on commit c4c3538

Please sign in to comment.