File tree Expand file tree Collapse file tree
main/java/org/pkl/core/stdlib/base
test/files/LanguageSnippetTests Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11/*
2- * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
2+ * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
@@ -190,7 +190,7 @@ public abstract static class toRadixString extends ExternalMethod1Node {
190190 @ Specialization
191191 @ TruffleBoundary
192192 protected String eval (long self , long radix ) {
193- return ( self < 0 ? "-" : "" ) + Long .toString (Math . abs ( self ) , (int ) radix );
193+ return Long .toString (self , (int ) radix );
194194 }
195195 }
196196
Original file line number Diff line number Diff line change 11amends "../snippetTest.pkl"
22
3+ import "pkl:math"
4+
35facts {
46 ["isEven" ] {
57 (- 124 ).isEven
@@ -92,7 +94,7 @@ examples {
9294 0 .floor
9395 (- 0 ).floor
9496 }
95-
97+
9698 ["toRadixString()" ] {
9799 123 .toRadixString(16 )
98100 123 .toRadixString(2 )
@@ -101,15 +103,17 @@ examples {
101103 (- 123 ).toRadixString(16 )
102104 (- 123 ).toRadixString(2 )
103105 (- 123 ).toRadixString(33 )
104-
106+
105107 0 .toRadixString(16 )
106108 0 .toRadixString(2 )
107109 0 .toRadixString(33 )
108-
110+
109111 (- 0 ).toRadixString(16 )
110112 (- 0 ).toRadixString(2 )
111113 (- 0 ).toRadixString(33 )
112-
114+
115+ math.minInt.toRadixString(10 )
116+
113117 module .catch(() -> (- 123 ).toRadixString(- 1 ))
114118 module .catch(() -> (- 123 ).toRadixString(64 ))
115119 }
@@ -159,7 +163,7 @@ examples {
159163 (- 123 ).toFixed(2 )
160164 0 .toFixed(3 )
161165 (- 0 ).toFixed(4 )
162-
166+
163167 123456789 .toFixed(1 )
164168 123456789 .toFixed(2 )
165169 123456789 .toFixed(3 )
Original file line number Diff line number Diff line change @@ -90,6 +90,7 @@ examples {
9090 "0"
9191 "0"
9292 "0"
93+ "-9223372036854775808"
9394 "Type constraint `this.isBetween(2, 36)` violated. Value: -1"
9495 "Type constraint `this.isBetween(2, 36)` violated. Value: 64"
9596 }
You can’t perform that action at this time.
0 commit comments