Better messages for abstract function invocation in kotlin-lib.js.

Cosmetics in StdLibGetOrElseTest.
This commit is contained in:
Pavel V. Talanov
2012-07-19 13:15:00 +04:00
parent d8d6dc1626
commit 63c42e13f9
2 changed files with 17 additions and 9 deletions
@@ -23,7 +23,7 @@ import junit.framework.Test;
*/ */
//NOTE: well, it has tests //NOTE: well, it has tests
@SuppressWarnings("JUnitTestCaseWithNoTests") @SuppressWarnings("JUnitTestCaseWithNoTests")
public class StdLibGetOtElseTest extends JsUnitTestBase { public final class StdLibGetOtElseTest extends JsUnitTestBase {
public static Test suite() throws Exception { public static Test suite() throws Exception {
return createTestSuiteForFile("libraries/stdlib/test/GetOrElseTest.kt"); return createTestSuiteForFile("libraries/stdlib/test/GetOrElseTest.kt");
} }
+16 -8
View File
@@ -63,15 +63,23 @@ var kotlin = {set:function (receiver, key, value) {
throw Kotlin.$new(Kotlin.Exceptions.NullPointerException)(); throw Kotlin.$new(Kotlin.Exceptions.NullPointerException)();
}; };
function throwAbstractFunctionInvocationError() { function throwAbstractFunctionInvocationError(funName) {
throw new TypeError("Function is abstract"); return function() {
var message;
if (funName !== undefined) {
message = "Function " + funName + " is abstract";
} else {
message = "Function is abstract";
}
throw new TypeError(message);
};
} }
Kotlin.Iterator = Kotlin.$createClass({ Kotlin.Iterator = Kotlin.$createClass({
initialize: function () { initialize: function () {
}, },
next: throwAbstractFunctionInvocationError, next: throwAbstractFunctionInvocationError("Iterator#next"),
get_hasNext: throwAbstractFunctionInvocationError get_hasNext: throwAbstractFunctionInvocationError("Iterator#get_hasNext")
}); });
var ArrayIterator = Kotlin.$createClass(Kotlin.Iterator, { var ArrayIterator = Kotlin.$createClass(Kotlin.Iterator, {
@@ -212,19 +220,19 @@ var kotlin = {set:function (receiver, key, value) {
Kotlin.Runnable = Kotlin.$createClass({ Kotlin.Runnable = Kotlin.$createClass({
initialize: function () { initialize: function () {
}, },
run: throwAbstractFunctionInvocationError run: throwAbstractFunctionInvocationError("Runnable#run")
}); });
Kotlin.Comparable = Kotlin.$createClass({ Kotlin.Comparable = Kotlin.$createClass({
initialize: function () { initialize: function () {
}, },
compareTo: throwAbstractFunctionInvocationError compareTo: throwAbstractFunctionInvocationError("Comparable#compareTo")
}); });
Kotlin.Appendable = Kotlin.$createClass({ Kotlin.Appendable = Kotlin.$createClass({
initialize: function () { initialize: function () {
}, },
append: throwAbstractFunctionInvocationError append: throwAbstractFunctionInvocationError("Appendable#append")
}); });
Kotlin.parseInt = function (str) { Kotlin.parseInt = function (str) {
@@ -358,7 +366,7 @@ var kotlin = {set:function (receiver, key, value) {
Kotlin.Comparator = Kotlin.$createClass({ Kotlin.Comparator = Kotlin.$createClass({
initialize: function () { initialize: function () {
}, },
compare: throwAbstractFunctionInvocationError compare: throwAbstractFunctionInvocationError("Comparator#compare")
}); });
var ComparatorImpl = Kotlin.$createClass(Kotlin.Comparator, { var ComparatorImpl = Kotlin.$createClass(Kotlin.Comparator, {