Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MichalMarsalek committed Mar 12, 2024
1 parent 0177cc8 commit 8bf7ed9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
6 changes: 6 additions & 0 deletions src/languages/golfscript/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,12 @@ const golfscriptLanguage: Language = {
"with_at_back[List]": 0,
"with_at[Table]": 0,
}),
mapOpsTo.func({
"ord_at[byte]": "=",
}),
mapOps({
"at[byte]": (a, b) => op["char[byte]"](func("=", a, b)),
}),
mapOpsTo.index({
"at[Array]": 0,
"at[List]": 0,
Expand Down
26 changes: 20 additions & 6 deletions src/languages/swift/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,6 @@ const swiftLanguage: Language = {
argv: () => builtin("CommandLine.arguments[1...]"),
"at[argv]": (a) =>
op["at[List]"](builtin("CommandLine.arguments"), succ(a)),
"ord[codepoint]": (a) => op["ord_at[codepoint]"](a, int(0n)),
"ord[byte]": (a) => op["ord_at[byte]"](a, int(0n)),
"at[byte]": (a, b) => op["char[byte]"](op["ord_at[byte]"](a, b)),
}),

decomposeIntLiteral(),
Expand All @@ -133,16 +130,15 @@ const swiftLanguage: Language = {
argv: () => builtin("CommandLine.arguments[1...]"),
"at[argv]": (a) =>
op["at[List]"](builtin("CommandLine.arguments"), succ(a)),
"ord[codepoint]": (a) => op["ord_at[codepoint]"](a, int(0n)),
"ord[byte]": (a) => op["ord_at[byte]"](a, int(0n)),
"at[byte]": (a, b) => op["char[byte]"](op["ord_at[byte]"](a, b)),
}),
implicitlyConvertPrintArg,
mapOps({
join: (a, b) =>
method(a, "joined", isText("")(b) ? [] : { separator: b }),
"ord_at[byte]": (a, b) =>
func("Int", indexCall(func("Array", prop(a, "utf8")), b)),
"ord[byte]": (a) =>
func("Int", indexCall(func("Array", prop(a, "utf8")), int(0))),
"at[codepoint]": (a, b) =>
func("String", indexCall(func("Array", a), b)),
"slice[codepoint]": (a, b, c) =>
Expand All @@ -152,6 +148,11 @@ const swiftLanguage: Language = {
"slice[List]": (a, b, c) => rangeIndexCall(a, b, op.add(b, c), int(1n)),
"ord_at[codepoint]": (a, b) =>
prop(indexCall(func("Array", prop(a, "unicodeScalars")), b), "value"),
"ord[codepoint]": (a) =>
prop(
indexCall(func("Array", prop(a, "unicodeScalars")), int(0)),
"value",
),
"char[byte]": (a) =>
func("String", postfix("!", func("UnicodeScalar", a))),
"char[codepoint]": (a) =>
Expand Down Expand Up @@ -309,6 +310,19 @@ const swiftLanguage: Language = {
"with_at[List]": 0,
"with_at[Table]": 0,
}),
mapOps({
"at[byte]": (a, b) =>
func(
"String",
postfix(
"!",
func(
"UnicodeScalar",
func("Int", indexCall(func("Array", prop(a, "utf8")), b)),
),
),
),
}),
mapOpsTo.index({
"at[Array]": 0,
"at[List]": 0,
Expand Down

0 comments on commit 8bf7ed9

Please sign in to comment.