Skip to content

Commit 63d5357

Browse files
Fix additional discrepancies found when importing go-jsonnet tests. (#436)
- Re-add pow6 test case. The difference for large numbers is insignificant (it's due to difference on how the jdk handles decimal exponents) - Fix tailstrict evaluation when default args are present. - Fix std.char - Fix |/^ bit operators
1 parent e3aea17 commit 63d5357

File tree

10 files changed

+19
-32
lines changed

10 files changed

+19
-32
lines changed

bench/src/main/scala/sjsonnet/MainBenchmark.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ object MainBenchmark {
3333
Map.empty[String, String],
3434
Map.empty[String, String],
3535
OsPath(wd),
36-
importer = SjsonnetMain.resolveImport(config.getOrderedJpaths.map(os.Path(_, wd)).map(OsPath(_)), None),
36+
importer = SjsonnetMain
37+
.resolveImport(config.getOrderedJpaths.map(os.Path(_, wd)).map(OsPath(_)), None),
3738
parseCache = parseCache
3839
)
3940
val renderer = new Renderer(new StringWriter, indent = 3)

bench/src/main/scala/sjsonnet/MaterializerBenchmark.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ class MaterializerBenchmark {
3333
Map.empty[String, String],
3434
OsPath(wd),
3535
importer = SjsonnetMain
36-
.resolveImport(config.getOrderedJpaths.map(os.Path(_, wd)).map(OsPath(_)).toIndexedSeq, None),
36+
.resolveImport(
37+
config.getOrderedJpaths.map(os.Path(_, wd)).map(OsPath(_)).toIndexedSeq,
38+
None
39+
),
3740
parseCache = new DefaultParseCache
3841
)
3942
value = interp.evaluate(os.read(path), OsPath(path)).getOrElse(???)

sjsonnet/src/sjsonnet/Evaluator.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -595,14 +595,14 @@ class Evaluator(
595595
case Expr.BinaryOp.OP_^ =>
596596
(l, r) match {
597597
case (l: Val.Num, r: Val.Num) =>
598-
Val.Num(pos, (l.asSafeLong ^ r.asSafeLong).toDouble)
598+
Val.Num(pos, (l.asLong ^ r.asLong).toDouble)
599599
case _ => fail()
600600
}
601601

602602
case Expr.BinaryOp.OP_| =>
603603
(l, r) match {
604604
case (l: Val.Num, r: Val.Num) =>
605-
Val.Num(pos, (l.asSafeLong | r.asSafeLong).toDouble)
605+
Val.Num(pos, (l.asLong | r.asLong).toDouble)
606606
case _ => fail()
607607
}
608608

sjsonnet/src/sjsonnet/Std.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ class Std(
596596
if (!Character.isValidCodePoint(c)) {
597597
Error.fail(s"Invalid unicode code point, got " + c)
598598
}
599-
Val.Str(pos, c.toChar.toString)
599+
Val.Str(pos, Character.toString(c))
600600
}
601601
}
602602

sjsonnet/src/sjsonnet/Val.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ object Val {
526526
case p => p.fileScope
527527
}
528528
// println(s"apply: argsL: ${argsL.length}, namedNames: $namedNames, paramNames: ${params.names.mkString(",")}")
529-
if (simple || tailstrictMode == TailstrictModeEnabled) {
529+
if (simple) {
530530
if (tailstrictMode == TailstrictModeEnabled) {
531531
argsL.foreach(_.force)
532532
}
@@ -585,6 +585,9 @@ object Val {
585585
)
586586
}
587587
}
588+
if (tailstrictMode == TailstrictModeEnabled) {
589+
argVals.foreach(_.force)
590+
}
588591
evalRhs(newScope, ev, funDefFileScope, outerPos)
589592
}
590593
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
// roughly the largest possible double
2-
std.pow(1.1, 7447.081)
2+
std.pow(1.1, 7447)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
179754255558423237941456473541041914055900576989066323324790225489927405882855355678287600996768561249516179005117487900995816670389973592784065259754879901383672166545582558984633189841112133404180226485873094649946308637416044832879263264479292996247265876810814717146304544813220293475007274508971205984256
1+
178371873262215010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
1-
RUNTIME ERROR: xxx
2-
-------------------------------------------------
3-
testdata/tailstrict3:1:16-27 function <foo>
4-
5-
local foo(x, y=error "xxx")=x;
6-
7-
-------------------------------------------------
8-
testdata/tailstrict3:2:1-8 $
9-
10-
foo(42) tailstrict
11-
12-
-------------------------------------------------
13-
During evaluation
14-
15-
1+
sjsonnet.Error: xxx
2+
at [Error].(sjsonnet/test/resources/go_test_suite/tailstrict3.jsonnet:1:16)
3+
at [Apply1].(sjsonnet/test/resources/go_test_suite/tailstrict3.jsonnet:2:4)

sjsonnet/test/src-js/sjsonnet/FileTests.scala

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,7 @@ object FileTests extends BaseFileTests {
2020
)
2121

2222
val goTestDataSkippedTests: Set[String] = Set(
23-
"bitwise_or9.jsonnet",
24-
"builtinChar6.jsonnet",
25-
"pow6.jsonnet",
2623
"object_invariant_plus.jsonnet",
27-
"tailstrict3.jsonnet",
2824
"stdlib_smoke_test.jsonnet",
2925
"builtinSha1.jsonnet",
3026
"builtinSha256.jsonnet",

sjsonnet/test/src-jvm-native/sjsonnet/FileTests.scala

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,7 @@ object FileTests extends BaseFileTests {
1919
Set.empty[String]
2020
})
2121
val goTestDataSkippedTests: Set[String] = Set(
22-
"bitwise_or9.jsonnet",
23-
"builtinChar6.jsonnet",
24-
"pow6.jsonnet",
25-
"object_invariant_plus.jsonnet",
26-
"tailstrict3.jsonnet"
22+
"object_invariant_plus.jsonnet"
2723
) ++ (if (isScalaNative)
2824
Set(
2925
"stdlib_smoke_test.jsonnet",

0 commit comments

Comments
 (0)