Skip to content

Commit

Permalink
#542 unit test for boxing issue
Browse files Browse the repository at this point in the history
  • Loading branch information
lgrignon committed Oct 5, 2019
1 parent 9c3104a commit 8a68a70
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.junit.Assert;
import org.junit.Test;

import source.calculus.Boxing;
import source.calculus.Chars;
import source.calculus.Integers;
import source.calculus.Longs;
Expand Down Expand Up @@ -80,6 +81,15 @@ public void testLongs() {
}, getSourceFile(Longs.class));
}

@Test
public void testBoxing() {
eval(ModuleKind.none, (logHandler, r) -> {
logHandler.assertNoProblems();
assertEquals(true, r.get("unboxedEquals"));

}, getSourceFile(Boxing.class));
}

@Test
public void testMathApi() {
eval(ModuleKind.none, (logHandler, r) -> {
Expand Down
17 changes: 17 additions & 0 deletions transpiler/src/test/java/source/calculus/Boxing.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package source.calculus;

import static jsweet.util.Lang.$export;

public class Boxing {

public static void main(String[] args) {
double a = 1;
Double d = new Double(1);
double b = d.doubleValue();
if (a == b) {
$export("unboxedEquals", true);
}

}

}

1 comment on commit 8a68a70

@Icare67
Copy link

@Icare67 Icare67 commented on 8a68a70 Oct 9, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. I'm using j4ts.
The generated code with j4ts is

            var a = 1;
            var d = new Number(1);
            var b = d;

without j4ts, I get

            var a = 1;
            var d = new Number(1).valueOf();
            var b = d;

I'm surprised that J4ts has an influence on such a simple example. I will report the bug on j4ts . Thanks

Please sign in to comment.