mirror of
https://github.com/apple/pkl.git
synced 2026-06-10 07:42:58 +02:00
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -190,7 +190,7 @@ public final class IntNodes {
|
||||
@Specialization
|
||||
@TruffleBoundary
|
||||
protected String eval(long self, long radix) {
|
||||
return (self < 0 ? "-" : "") + Long.toString(Math.abs(self), (int) radix);
|
||||
return Long.toString(self, (int) radix);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
amends "../snippetTest.pkl"
|
||||
|
||||
import "pkl:math"
|
||||
|
||||
facts {
|
||||
["isEven"] {
|
||||
(-124).isEven
|
||||
@@ -92,7 +94,7 @@ examples {
|
||||
0.floor
|
||||
(-0).floor
|
||||
}
|
||||
|
||||
|
||||
["toRadixString()"] {
|
||||
123.toRadixString(16)
|
||||
123.toRadixString(2)
|
||||
@@ -101,15 +103,17 @@ examples {
|
||||
(-123).toRadixString(16)
|
||||
(-123).toRadixString(2)
|
||||
(-123).toRadixString(33)
|
||||
|
||||
|
||||
0.toRadixString(16)
|
||||
0.toRadixString(2)
|
||||
0.toRadixString(33)
|
||||
|
||||
|
||||
(-0).toRadixString(16)
|
||||
(-0).toRadixString(2)
|
||||
(-0).toRadixString(33)
|
||||
|
||||
|
||||
math.minInt.toRadixString(10)
|
||||
|
||||
module.catch(() -> (-123).toRadixString(-1))
|
||||
module.catch(() -> (-123).toRadixString(64))
|
||||
}
|
||||
@@ -159,7 +163,7 @@ examples {
|
||||
(-123).toFixed(2)
|
||||
0.toFixed(3)
|
||||
(-0).toFixed(4)
|
||||
|
||||
|
||||
123456789.toFixed(1)
|
||||
123456789.toFixed(2)
|
||||
123456789.toFixed(3)
|
||||
|
||||
@@ -90,6 +90,7 @@ examples {
|
||||
"0"
|
||||
"0"
|
||||
"0"
|
||||
"-9223372036854775808"
|
||||
"Type constraint `this.isBetween(2, 36)` violated. Value: -1"
|
||||
"Type constraint `this.isBetween(2, 36)` violated. Value: 64"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user