From f6927a72af4b32a5fa8276e55647c06d03afc60d Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Thu, 28 Nov 2013 17:42:06 +0400 Subject: [PATCH] Fixes some bugs --- .../org/junit/AssertNativeGenerator.java | 2 +- .../org/teavm/classlib/junit-support.js | 18 ++++-------------- .../teavm/codegen/DefaultNamingStrategy.java | 4 ++-- .../java/org/teavm/javascript/Renderer.java | 4 ++-- 4 files changed, 9 insertions(+), 19 deletions(-) diff --git a/teavm-classlib/src/main/java/org/teavm/classlib/org/junit/AssertNativeGenerator.java b/teavm-classlib/src/main/java/org/teavm/classlib/org/junit/AssertNativeGenerator.java index 740177ec8..d1b5e586f 100644 --- a/teavm-classlib/src/main/java/org/teavm/classlib/org/junit/AssertNativeGenerator.java +++ b/teavm-classlib/src/main/java/org/teavm/classlib/org/junit/AssertNativeGenerator.java @@ -20,6 +20,6 @@ public class AssertNativeGenerator implements Generator { } private void generateFail(SourceWriter writer) { - writer.append("throw new JUnitAssertionFailure();").newLine(); + writer.append("throw new Error();").newLine(); } } diff --git a/teavm-classlib/src/main/resources/org/teavm/classlib/junit-support.js b/teavm-classlib/src/main/resources/org/teavm/classlib/junit-support.js index 241e87e70..62981a432 100644 --- a/teavm-classlib/src/main/resources/org/teavm/classlib/junit-support.js +++ b/teavm-classlib/src/main/resources/org/teavm/classlib/junit-support.js @@ -1,6 +1,3 @@ -JUnitAssertionFailure = function() {} -JUnitAssertionFailure.prototype = new Error(); - currentTestReportBody = null; runTestCase = function(instance, methodName, realMethodName) { @@ -17,17 +14,10 @@ runTestCase = function(instance, methodName, realMethodName) { instance[realMethodName](); statusCell.appendChild(document.createTextNode("ok")); } catch (e) { - if (e instanceof JUnitAssertionFailure) { - statusCell.appendChild(document.createTextNode("assertion failed")); - var exceptionText = document.createElement("pre"); - exceptionText.appendChild(document.createTextNode(e.stack)); - exceptionCell.appendChild(exceptionText); - } else { - statusCell.appendChild(document.createTextNode("unexpected exception")); - var exceptionText = document.createElement("pre"); - exceptionText.appendChild(document.createTextNode(e.stack)); - exceptionCell.appendChild(exceptionText); - } + statusCell.appendChild(document.createTextNode("unexpected exception")); + var exceptionText = document.createElement("pre"); + exceptionText.appendChild(document.createTextNode(e.stack)); + exceptionCell.appendChild(exceptionText); } } diff --git a/teavm-core/src/main/java/org/teavm/codegen/DefaultNamingStrategy.java b/teavm-core/src/main/java/org/teavm/codegen/DefaultNamingStrategy.java index 751f26c13..07b2a80f5 100644 --- a/teavm-core/src/main/java/org/teavm/codegen/DefaultNamingStrategy.java +++ b/teavm-core/src/main/java/org/teavm/codegen/DefaultNamingStrategy.java @@ -59,7 +59,7 @@ public class DefaultNamingStrategy implements NamingStrategy { if (methodHolder.getModifiers().contains(ElementModifier.STATIC) || method.getDescriptor().getName().equals("") || methodHolder.getLevel() == AccessLevel.PRIVATE) { - String key = method.getClassName() + "#" + method.toString(); + String key = method.toString(); String alias = privateAliases.get(key); if (alias == null) { alias = aliasProvider.getAlias(method); @@ -67,7 +67,7 @@ public class DefaultNamingStrategy implements NamingStrategy { } return alias; } else { - String key = method.toString(); + String key = method.getDescriptor().toString(); String alias = aliases.get(key); if (alias == null) { alias = aliasProvider.getAlias(method); diff --git a/teavm-core/src/main/java/org/teavm/javascript/Renderer.java b/teavm-core/src/main/java/org/teavm/javascript/Renderer.java index e3ddc3f3b..c45dc0712 100644 --- a/teavm-core/src/main/java/org/teavm/javascript/Renderer.java +++ b/teavm-core/src/main/java/org/teavm/javascript/Renderer.java @@ -75,8 +75,8 @@ public class Renderer implements ExprVisitor, StatementVisitor { writer.append("for (var i = 0; i < str.length; i = (i + 1) | 0) {").indent().newLine(); writer.append("characters[i] = str.charCodeAt(i);").newLine(); writer.outdent().append("}").newLine(); - writer.append("return $rt_init(").appendClass("java.lang.String").append(", '") - .appendMethod(stringCons).append("', characters);").newLine(); + writer.append("return ").appendClass("java.lang.String").append(".") + .appendMethod(stringCons).append("(characters);").newLine(); writer.outdent().append("}").newLine(); }