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
@SuppressWarnings("JUnitTestCaseWithNoTests")
public class StdLibGetOtElseTest extends JsUnitTestBase {
public final class StdLibGetOtElseTest extends JsUnitTestBase {
public static Test suite() throws Exception {
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)();
};
function throwAbstractFunctionInvocationError() {
throw new TypeError("Function is abstract");
function throwAbstractFunctionInvocationError(funName) {
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({
initialize: function () {
},
next: throwAbstractFunctionInvocationError,
get_hasNext: throwAbstractFunctionInvocationError
next: throwAbstractFunctionInvocationError("Iterator#next"),
get_hasNext: throwAbstractFunctionInvocationError("Iterator#get_hasNext")
});
var ArrayIterator = Kotlin.$createClass(Kotlin.Iterator, {
@@ -212,19 +220,19 @@ var kotlin = {set:function (receiver, key, value) {
Kotlin.Runnable = Kotlin.$createClass({
initialize: function () {
},
run: throwAbstractFunctionInvocationError
run: throwAbstractFunctionInvocationError("Runnable#run")
});
Kotlin.Comparable = Kotlin.$createClass({
initialize: function () {
},
compareTo: throwAbstractFunctionInvocationError
compareTo: throwAbstractFunctionInvocationError("Comparable#compareTo")
});
Kotlin.Appendable = Kotlin.$createClass({
initialize: function () {
},
append: throwAbstractFunctionInvocationError
append: throwAbstractFunctionInvocationError("Appendable#append")
});
Kotlin.parseInt = function (str) {
@@ -358,7 +366,7 @@ var kotlin = {set:function (receiver, key, value) {
Kotlin.Comparator = Kotlin.$createClass({
initialize: function () {
},
compare: throwAbstractFunctionInvocationError
compare: throwAbstractFunctionInvocationError("Comparator#compare")
});
var ComparatorImpl = Kotlin.$createClass(Kotlin.Comparator, {