Adjust js stdlib to isEmpty transformation
This commit is contained in:
@@ -5,5 +5,5 @@ import java.util.ArrayList;
|
||||
fun box(): Boolean {
|
||||
val a = ArrayList<Int>();
|
||||
a.add(3)
|
||||
return !(a.isEmpty()) && (ArrayList<Int>().isEmpty());
|
||||
return !(a.isEmpty) && (ArrayList<Int>().isEmpty);
|
||||
}
|
||||
+2
-2
@@ -28,7 +28,7 @@ fun box(): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
if (a.isEmpty() || !ArrayList<Int>().isEmpty()) {
|
||||
if (a.isEmpty || !ArrayList<Int>().isEmpty) {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ fun box(): Boolean {
|
||||
assertEquals(a, b, "a == b")
|
||||
|
||||
a.clear()
|
||||
assertEquals(true, a.isEmpty(), "a.isEmpty()")
|
||||
assertEquals(true, a.isEmpty, "a.isEmpty")
|
||||
|
||||
|
||||
assertEquals(arrayOf(1, 500, 2, 3), list.toTypedArray(), "list.toTypedArray()")
|
||||
|
||||
+5
-3
@@ -398,8 +398,10 @@
|
||||
}
|
||||
return true;
|
||||
},
|
||||
isEmpty: function () {
|
||||
return this.size === 0;
|
||||
isEmpty: {
|
||||
get: function () {
|
||||
return this.size === 0;
|
||||
}
|
||||
},
|
||||
iterator: function () {
|
||||
// TODO: Do not implement mutable iterator() this way, make abstract
|
||||
@@ -970,7 +972,7 @@
|
||||
});
|
||||
|
||||
Kotlin.collectionsMax = function (c, comp) {
|
||||
if (c.isEmpty()) {
|
||||
if (c.isEmpty) {
|
||||
//TODO: which exception?
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
Vendored
+17
-11
@@ -347,9 +347,11 @@
|
||||
bucketsByHash = {};
|
||||
};
|
||||
|
||||
this.isEmpty = function () {
|
||||
return !buckets.length;
|
||||
};
|
||||
Object.defineProperty(this, "isEmpty", {
|
||||
get: function () {
|
||||
return !buckets.length;
|
||||
}
|
||||
});
|
||||
|
||||
var createBucketAggregator = function (bucketFuncName) {
|
||||
return function () {
|
||||
@@ -562,8 +564,10 @@
|
||||
iterator: function () {
|
||||
return new Kotlin.PrimitiveHashMapValuesIterator(this.map.map, Object.keys(this.map.map));
|
||||
},
|
||||
isEmpty: function () {
|
||||
return this.map.isEmpty();
|
||||
isEmpty: {
|
||||
get: function () {
|
||||
return this.map.isEmpty;
|
||||
}
|
||||
},
|
||||
size: {
|
||||
get: function () {
|
||||
@@ -594,8 +598,10 @@
|
||||
return this.$size;
|
||||
}
|
||||
},
|
||||
isEmpty: function () {
|
||||
return this.$size === 0;
|
||||
isEmpty: {
|
||||
get: function () {
|
||||
return this.$size === 0;
|
||||
}
|
||||
},
|
||||
containsKey_za3rmp$: function (key) {
|
||||
// TODO: should process "__proto__" separately?
|
||||
@@ -669,7 +675,7 @@
|
||||
return this.map;
|
||||
},
|
||||
toString: function() {
|
||||
if (this.isEmpty()) return "{}";
|
||||
if (this.isEmpty) return "{}";
|
||||
var map = this.map;
|
||||
var isFirst = true;
|
||||
var builder = "{";
|
||||
@@ -1039,9 +1045,9 @@
|
||||
return hashTable.size;
|
||||
}});
|
||||
|
||||
this.isEmpty = function () {
|
||||
return hashTable.isEmpty();
|
||||
};
|
||||
Object.defineProperty(this, "isEmpty", { get: function () {
|
||||
return hashTable.isEmpty;
|
||||
}});
|
||||
|
||||
this.clone = function () {
|
||||
var h = new HashSet(hashingFunction, equalityFunction);
|
||||
|
||||
@@ -11,7 +11,7 @@ fun box(): String {
|
||||
assertTrue((stdlib_emptyListClass(): Any) is List<*>, "stdlib_emptyListClass() is List<*> #2")
|
||||
assertTrue((stdlib_emptyListClass(): Any) !is ArrayList<*>, "stdlib_emptyListClass() !is ArrayList<*>")
|
||||
|
||||
assertTrue(stdlib_emptyListClass().isEmpty(), "stdlib_emptyListClass().isEmpty()")
|
||||
assertTrue(stdlib_emptyListClass().isEmpty, "stdlib_emptyListClass().isEmpty")
|
||||
assertTrue(stdlib_emptyListClass().size() == 0, "stdlib_emptyListClass().size() == 0")
|
||||
|
||||
return "OK"
|
||||
|
||||
Reference in New Issue
Block a user