Skip to content

Commit

Permalink
Fix in
Browse files Browse the repository at this point in the history
  • Loading branch information
Seggan committed Nov 2, 2023
1 parent 518704f commit 08101f7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 22 deletions.
5 changes: 5 additions & 0 deletions docs/index.papyri
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ This will create a JAR file in `app/build/libs` that can be run with `java -jar

@h2 Changelog

@h3 { v1.2.1 }
[
{ Fixed `in` giving wrong result }
]

@h3 { v1.2.0 }
[
{ Added a ton of functions to `path` },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@ internal fun initString() = buildTable { table ->
)
}
table["__contains__"] = twoArgFunction(true) { self, key ->
if (!self.stringValue().contains(key.stringValue())) {
Value.Boolean.of(self.lookUp(key) != null)
} else {
Value.Boolean.TRUE
}
self.stringValue().contains(key.stringValue()).metisValue()
}
table["__eq__"] = twoArgFunction(true) { self, other ->
if (other !is Value.String) {
Expand Down Expand Up @@ -114,9 +110,6 @@ internal fun initNumber() = buildTable { table ->
table["__neg__"] = oneArgFunction(true) { self ->
(-self.doubleValue()).metisValue()
}
table["__contains__"] = twoArgFunction(true) { self, key ->
Value.Boolean.of(self.lookUp(key) != null)
}
table["string_with_radix"] = twoArgFunction(true) { self, radix ->
self.intValue().toString(radix.intValue()).metisValue()
}
Expand Down Expand Up @@ -148,9 +141,6 @@ internal fun initBoolean() = buildTable { table ->
Value.Boolean.of(self.convertTo<Value.Boolean>().value == other.convertTo<Value.Boolean>().value)
}
}
table["__contains__"] = twoArgFunction(true) { self, key ->
Value.Boolean.of(self.lookUp(key) != null)
}

table["parse"] = oneArgFunction { s ->
s.stringValue().toBoolean().metisValue()
Expand All @@ -176,7 +166,7 @@ internal fun initTable() = Value.Table(mutableMapOf(), null).also { table ->
self.convertTo<Value.Table>().size.metisValue()
}
table["__contains__"] = twoArgFunction(true) { self, key ->
Value.Boolean.of(self.lookUp(key) != null)
Value.Boolean.of(key in self.convertTo<Value.Table>())
}
table["keys"] = oneArgFunction(true) { self ->
self.convertTo<Value.Table>().keys.metisValue()
Expand Down Expand Up @@ -213,11 +203,7 @@ internal fun initList() = buildTable { table ->
self.convertTo<Value.List>().size.metisValue()
}
table["__contains__"] = twoArgFunction(true) { self, key ->
if (key !in self.convertTo<Value.List>()) {
Value.Boolean.of(self.lookUp(key) != null)
} else {
Value.Boolean.TRUE
}
Value.Boolean.of(key in self.convertTo<Value.List>())
}
table["append"] = twoArgFunction(true) { self, value ->
self.convertTo<Value.List>().add(value)
Expand Down Expand Up @@ -269,11 +255,7 @@ internal fun initBytes() = buildTable { table ->
self.convertTo<Value.Bytes>().value.size.metisValue()
}
table["__contains__"] = twoArgFunction(true) { self, key ->
if (key.intValue().toByte() !in self.convertTo<Value.Bytes>().value) {
Value.Boolean.of(self.lookUp(key) != null)
} else {
Value.Boolean.TRUE
}
Value.Boolean.of(key.intValue().toByte() in self.convertTo<Value.Bytes>().value)
}
table["decode"] = twoArgFunction(true) { self, encoding ->
val actualEncoding =
Expand Down

0 comments on commit 08101f7

Please sign in to comment.