Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
appinventor-sources
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
appinventor-sources
Commits
34a1cf73
Commit
34a1cf73
authored
Feb 04, 2019
by
Evan W. Patton
Committed by
Jeffrey Schiller
Feb 03, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Correctly convert bignums to strings in YailList (#1546)
Change-Id: Ia3b29e30091e88e1db0fb5ec02c6b0d270c17f15
parent
9c6edf75
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
4 deletions
+18
-4
appinventor/components/src/com/google/appinventor/components/runtime/util/YailList.java
.../google/appinventor/components/runtime/util/YailList.java
+7
-2
appinventor/components/src/com/google/appinventor/components/runtime/util/YailNumberToString.java
...pinventor/components/runtime/util/YailNumberToString.java
+1
-1
appinventor/components/tests/com/google/appinventor/components/runtime/util/YailListTest.java
...gle/appinventor/components/runtime/util/YailListTest.java
+10
-1
No files found.
appinventor/components/src/com/google/appinventor/components/runtime/util/YailList.java
View file @
34a1cf73
// -*- mode: java; c-basic-offset: 2; -*-
// Copyright 2009-2011 Google, All Rights reserved
// Copyright 2011-201
2
MIT, All rights reserved
// Copyright 2011-201
9
MIT, All rights reserved
// Released under the Apache License, Version 2.0
// http://www.apache.org/licenses/LICENSE-2.0
...
...
@@ -10,6 +10,7 @@ import com.google.appinventor.components.runtime.errors.YailRuntimeError;
import
gnu.lists.LList
;
import
gnu.lists.Pair
;
import
gnu.math.IntNum
;
import
org.json.JSONException
;
...
...
@@ -119,7 +120,11 @@ public class YailList extends Pair {
* @return the string
*/
public
static
String
YailListElementToString
(
Object
element
)
{
if
(
Number
.
class
.
isInstance
(
element
))
{
if
(
element
instanceof
IntNum
)
{
return
((
IntNum
)
element
).
toString
(
10
);
}
else
if
(
element
instanceof
Long
)
{
return
Long
.
toString
((
Long
)
element
);
}
else
if
(
Number
.
class
.
isInstance
(
element
))
{
return
YailNumberToString
.
format
(((
Number
)
element
).
doubleValue
());
}
else
{
return
String
.
valueOf
(
element
);
...
...
appinventor/components/src/com/google/appinventor/components/runtime/util/YailNumberToString.java
View file @
34a1cf73
...
...
@@ -58,7 +58,7 @@ public final class YailNumberToString {
public
static
String
format
(
double
number
)
{
// We will print integer values without a decimal point.
if
(
number
==
Math
.
rint
(
number
))
{
return
String
.
valueOf
((
int
)
number
);
return
String
.
valueOf
((
long
)
number
);
}
else
{
double
mag
=
Math
.
abs
(
number
);
if
(
mag
<
BIGBOUND
&&
mag
>
SMALLBOUND
)
{
...
...
appinventor/components/tests/com/google/appinventor/components/runtime/util/YailListTest.java
View file @
34a1cf73
// -*- mode: java; c-basic-offset: 2; -*-
// Copyright 2009-2011 Google, All Rights reserved
// Copyright 2011-201
2
MIT, All rights reserved
// Copyright 2011-201
9
MIT, All rights reserved
// Released under the Apache License, Version 2.0
// http://www.apache.org/licenses/LICENSE-2.0
package
com.google.appinventor.components.runtime.util
;
import
gnu.lists.FString
;
import
gnu.math.IntNum
;
import
junit.framework.TestCase
;
...
...
@@ -203,4 +204,12 @@ public class YailListTest extends TestCase {
// this is the intended behavior
}
}
public
void
testBigNumsInStringArray
()
{
YailList
list
=
YailList
.
makeList
(
new
Object
[]
{
IntNum
.
make
(
Long
.
MAX_VALUE
),
(
Long
)
Long
.
MAX_VALUE
});
String
[]
strings
=
list
.
toStringArray
();
assertEquals
(
2
,
strings
.
length
);
assertEquals
(
Long
.
toString
(
Long
.
MAX_VALUE
),
strings
[
0
]);
assertEquals
(
Long
.
toString
(
Long
.
MAX_VALUE
),
strings
[
1
]);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment