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