koatl 0.3.18__tar.gz → 0.3.20__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {koatl-0.3.18 → koatl-0.3.20}/Cargo.lock +1 -1
- {koatl-0.3.18 → koatl-0.3.20}/PKG-INFO +1 -1
- {koatl-0.3.18 → koatl-0.3.20}/koatl/Cargo.toml +1 -1
- {koatl-0.3.18 → koatl-0.3.20}/koatl/python/koatl/std/iter.tl +9 -5
- {koatl-0.3.18 → koatl-0.3.20}/koatl/src/emit_py.rs +8 -2
- koatl-0.3.20/koatl/tests/e2e/base/fstr.tl +51 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/test_iterable.tl +16 -14
- {koatl-0.3.18 → koatl-0.3.20}/koatl-parser/src/lexer.rs +4 -2
- {koatl-0.3.18 → koatl-0.3.20}/python/koatl/std/iter.tl +9 -5
- koatl-0.3.18/koatl/tests/e2e/base/fstr.tl +0 -27
- {koatl-0.3.18 → koatl-0.3.20}/Cargo.toml +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/README.md +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/.github/workflows/CI.yml +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/.gitignore +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/LICENSE +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/README.md +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/python/koatl/__init__.py +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/python/koatl/__main__.py +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/python/koatl/cli.py +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/python/koatl/notebook/__init__.py +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/python/koatl/notebook/magic.py +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/python/koatl/prelude/__init__.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/python/koatl/runtime/__init__.py +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/python/koatl/runtime/meta_finder.py +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/python/koatl/runtime/record.py +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/python/koatl/runtime/vattr.py +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/python/koatl/std/__init__.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/python/koatl/std/control/__init__.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/python/koatl/std/control/async.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/python/koatl/std/control/base.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/python/koatl/std/control/do.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/python/koatl/std/control/env.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/python/koatl/std/control/memo.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/python/koatl/std/control/result.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/python/koatl/std/data/__init__.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/python/koatl/std/data/list.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/python/koatl/std/data/record.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/python/koatl/std/ext.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/python/koatl/std/io.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/python/koatl/std/json.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/python/koatl/std/lazy_module.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/python/koatl/std/pickle.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/python/koatl/std/re.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/python/koatl/std/trait.py +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/requirements.txt +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/src/lib.rs +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/conftest.py +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/e2e/base/arguments.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/e2e/base/containers.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/e2e/base/data.txt +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/e2e/base/decorators.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/e2e/base/destructure-for-and-fn.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/e2e/base/destructure.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/e2e/base/escape_ident.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/e2e/base/functions.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/e2e/base/generator.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/e2e/base/if_expr.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/e2e/base/imports.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/e2e/base/imports2.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/e2e/base/loops.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/e2e/base/match.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/e2e/base/nary-list.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/e2e/base/placeholder.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/e2e/base/precedence.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/e2e/base/scopes.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/e2e/base/semantic_whitespace.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/e2e/base/short_circuit.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/e2e/base/with.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/e2e/prelude/async.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/e2e/prelude/aug_assign.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/e2e/prelude/coal.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/e2e/prelude/env.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/e2e/prelude/iterables.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/e2e/prelude/list.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/e2e/prelude/memo.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/e2e/prelude/record.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/e2e/prelude/result.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/e2e/prelude/slice.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/e2e/prelude/try.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/e2e/prelude/virtual.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/e2e/test_modules/module0.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/e2e/test_modules/module1.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/e2e/test_modules/module2.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/fail-parse/arguments_mixed_defaults.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/fail-parse/arguments_multiple_kwargs.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/fail-parse/arguments_multiple_kwonly_markers.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/fail-parse/arguments_multiple_posonly_markers.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/fail-parse/arguments_multiple_varargs.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/fail-parse/arguments_posonly_after_kwonly.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/fail-parse/arguments_vararg_and_kwonly_marker.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/fail-parse/unmatched_closing_delimiter.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/parse/arith.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/parse/assign.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/parse/block-comments.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/parse/deco.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/parse/func.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/parse/matches.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/parse/mutual-recursion.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/parse/numbers.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/parse/operators.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/test_e2e.py +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/test_parse.py +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/test_parse_fail.py +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/test_re.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl/tests/util/__init__.py +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl-core/Cargo.toml +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl-core/src/ast.rs +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl-core/src/ast_builder.rs +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl-core/src/inference.rs +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl-core/src/lib.rs +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl-core/src/lift_cst.rs +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl-core/src/main.rs +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl-core/src/py/ast.rs +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl-core/src/py/ast_builder.rs +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl-core/src/py/emit.rs +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl-core/src/py/mod.rs +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl-core/src/resolve_scopes.rs +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl-core/src/transform.rs +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl-core/src/types.rs +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl-core/src/util.rs +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl-parser/Cargo.toml +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl-parser/src/cst.rs +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl-parser/src/lib.rs +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl-parser/src/parser.rs +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/koatl-parser/src/simple_fmt.rs +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/pyproject.toml +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/python/koatl/__init__.py +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/python/koatl/__main__.py +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/python/koatl/cli.py +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/python/koatl/notebook/__init__.py +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/python/koatl/notebook/magic.py +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/python/koatl/prelude/__init__.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/python/koatl/runtime/__init__.py +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/python/koatl/runtime/meta_finder.py +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/python/koatl/runtime/record.py +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/python/koatl/runtime/vattr.py +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/python/koatl/std/__init__.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/python/koatl/std/control/__init__.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/python/koatl/std/control/async.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/python/koatl/std/control/base.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/python/koatl/std/control/do.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/python/koatl/std/control/env.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/python/koatl/std/control/memo.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/python/koatl/std/control/result.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/python/koatl/std/data/__init__.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/python/koatl/std/data/list.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/python/koatl/std/data/record.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/python/koatl/std/ext.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/python/koatl/std/io.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/python/koatl/std/json.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/python/koatl/std/lazy_module.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/python/koatl/std/pickle.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/python/koatl/std/re.tl +0 -0
- {koatl-0.3.18 → koatl-0.3.20}/python/koatl/std/trait.py +0 -0
|
@@ -84,16 +84,20 @@ export Iterable = class(Traversable, Trait):
|
|
|
84
84
|
|
|
85
85
|
impl()
|
|
86
86
|
|
|
87
|
-
flat_map = (self, f) =>
|
|
87
|
+
flat_map = (self, f=None) =>
|
|
88
|
+
if f === None:
|
|
89
|
+
itertools.chain.from_iterable(self.iter)
|
|
90
|
+
else:
|
|
91
|
+
itertools.chain.from_iterable(self.iter.map(f))
|
|
88
92
|
|
|
89
|
-
|
|
93
|
+
reversed = self => reversed(list(self.iter))
|
|
90
94
|
|
|
91
|
-
|
|
95
|
+
sorted = (self, key=None, reverse=False) =>
|
|
92
96
|
sorted(self.iter, key=key, reverse=reverse)
|
|
93
97
|
|
|
94
98
|
copy = self => itertools.tee(self.iter)
|
|
95
99
|
|
|
96
|
-
|
|
100
|
+
tally = (self, f=None) =>
|
|
97
101
|
let acc = 0
|
|
98
102
|
if f === None:
|
|
99
103
|
for _ in self:
|
|
@@ -187,7 +191,7 @@ export Iterable = class(Traversable, Trait):
|
|
|
187
191
|
impl()
|
|
188
192
|
|
|
189
193
|
join = (self, sep="") =>
|
|
190
|
-
sep.join(self.map(str))
|
|
194
|
+
sep.join(self.iter.map(str))
|
|
191
195
|
|
|
192
196
|
sum = self =>
|
|
193
197
|
let acc = 0
|
|
@@ -708,11 +708,17 @@ impl<'src> PyExprExt<'src> for SPyExpr<'src> {
|
|
|
708
708
|
PyFstrPart::Str(s) => {
|
|
709
709
|
values.push(ctx.ast_node("Constant", (s.as_ref(),), &self.tl_span)?);
|
|
710
710
|
}
|
|
711
|
-
PyFstrPart::Expr(expr,
|
|
711
|
+
PyFstrPart::Expr(expr, format_spec) => {
|
|
712
712
|
let expr_ast = expr.emit_py(ctx)?;
|
|
713
|
+
let format_spec_ast = if let Some(spec) = format_spec {
|
|
714
|
+
spec.emit_py(ctx)?
|
|
715
|
+
} else {
|
|
716
|
+
ctx.py.None()
|
|
717
|
+
};
|
|
718
|
+
|
|
713
719
|
values.push(ctx.ast_node(
|
|
714
720
|
"FormattedValue",
|
|
715
|
-
(expr_ast, -1,
|
|
721
|
+
(expr_ast, -1, format_spec_ast),
|
|
716
722
|
&self.tl_span,
|
|
717
723
|
)?);
|
|
718
724
|
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import util.assert_eq
|
|
2
|
+
|
|
3
|
+
assert_eq(f"{1}", "1")
|
|
4
|
+
|
|
5
|
+
x = 1
|
|
6
|
+
|
|
7
|
+
fstr = f"x = {x + 1}"
|
|
8
|
+
assert_eq(fstr, "x = 2")
|
|
9
|
+
|
|
10
|
+
fstr = f"x = {(y => y)(x)}"
|
|
11
|
+
assert_eq(fstr, "x = 1")
|
|
12
|
+
|
|
13
|
+
fstr = f"={(
|
|
14
|
+
let a = 1
|
|
15
|
+
let b = 2
|
|
16
|
+
let c = 3
|
|
17
|
+
a * b * c
|
|
18
|
+
)}="
|
|
19
|
+
assert_eq(fstr, "=6=")
|
|
20
|
+
|
|
21
|
+
assert_eq(f"{{}}", "{}")
|
|
22
|
+
assert_eq(f"{{{1}}}", "{1}")
|
|
23
|
+
|
|
24
|
+
assert_eq(f"""
|
|
25
|
+
|
|
26
|
+
{{1}}
|
|
27
|
+
{2 * 5}""", "\n\n{1}\n10")
|
|
28
|
+
|
|
29
|
+
# Test format specifiers
|
|
30
|
+
num = 42
|
|
31
|
+
assert_eq(f"{num%d}", "42")
|
|
32
|
+
assert_eq(f"{num%05d}", "00042")
|
|
33
|
+
assert_eq(f"{num%>5d}", " 42")
|
|
34
|
+
assert_eq(f"{num%<5d}", "42 ")
|
|
35
|
+
assert_eq(f"{num%^5d}", " 42 ")
|
|
36
|
+
|
|
37
|
+
pi = 3.14159
|
|
38
|
+
assert_eq(f"{pi%.2f}", "3.14")
|
|
39
|
+
assert_eq(f"{pi%.4f}", "3.1416")
|
|
40
|
+
|
|
41
|
+
hex_num = 255
|
|
42
|
+
assert_eq(f"{hex_num%x}", "ff")
|
|
43
|
+
assert_eq(f"{hex_num%X}", "FF")
|
|
44
|
+
assert_eq(f"{hex_num%#x}", "0xff")
|
|
45
|
+
|
|
46
|
+
# Test multiple format specs in one string
|
|
47
|
+
assert_eq(f"{num%05d} and {pi%.2f}", "00042 and 3.14")
|
|
48
|
+
|
|
49
|
+
# Test format spec with expressions
|
|
50
|
+
assert_eq(f"{1 + 1%d}", "2")
|
|
51
|
+
assert_eq(f"{(10 * 5)%03d}", "050")
|
|
@@ -57,11 +57,14 @@ test_all = () =>
|
|
|
57
57
|
assert_eq([].all(x => x > 0), True)
|
|
58
58
|
assert_eq([True, True, True].all(x => x), True)
|
|
59
59
|
|
|
60
|
-
|
|
61
|
-
#
|
|
62
|
-
assert_eq([1, 2, 3, 4, 5].iter.
|
|
63
|
-
assert_eq([
|
|
64
|
-
assert_eq(
|
|
60
|
+
test_tally = () =>
|
|
61
|
+
# tally() works on Iterable trait via .iter
|
|
62
|
+
assert_eq([1, 2, 3, 4, 5].iter.tally(), 5)
|
|
63
|
+
assert_eq([].iter.tally(), 0)
|
|
64
|
+
assert_eq((..10).tally(), 10)
|
|
65
|
+
assert_eq([1, 2, 3, 4, 5].iter.tally(x => x > 2), 3)
|
|
66
|
+
assert_eq([1, 2, 3, 4, 5].iter.tally(x => x %% 2 == 0), 2)
|
|
67
|
+
assert_eq([1, 2, 3].iter.tally(x => x > 10), 0)
|
|
65
68
|
|
|
66
69
|
test_take = () =>
|
|
67
70
|
assert_eq([1, 2, 3, 4, 5].take(3).list(), [1, 2, 3])
|
|
@@ -104,16 +107,15 @@ test_cycle = () =>
|
|
|
104
107
|
assert_eq([1, 2, 3].cycle().take(7).list(), [1, 2, 3, 1, 2, 3, 1])
|
|
105
108
|
assert_eq([5].cycle().take(3).list(), [5, 5, 5])
|
|
106
109
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
assert_eq(list([1
|
|
110
|
-
assert_eq(list([
|
|
111
|
-
assert_eq(list([].iter.reverse()), [])
|
|
110
|
+
test_reversed = () =>
|
|
111
|
+
assert_eq(list([1, 2, 3, 4, 5].reversed()), [5, 4, 3, 2, 1])
|
|
112
|
+
assert_eq(list([1].reversed()), [1])
|
|
113
|
+
assert_eq(list([].reversed()), [])
|
|
112
114
|
|
|
113
|
-
|
|
114
|
-
assert_eq([3, 1, 4, 1, 5].iter.
|
|
115
|
-
assert_eq(["c", "a", "b"].iter.
|
|
116
|
-
assert_eq([].iter.
|
|
115
|
+
test_sorted = () =>
|
|
116
|
+
assert_eq([3, 1, 4, 1, 5].iter.sorted().list(), [1, 1, 3, 4, 5])
|
|
117
|
+
assert_eq(["c", "a", "b"].iter.sorted().list(), ["a", "b", "c"])
|
|
118
|
+
assert_eq([].iter.sorted().list(), [])
|
|
117
119
|
|
|
118
120
|
test_join = () =>
|
|
119
121
|
assert_eq(["a", "b", "c"].join(", "), "a, b, c")
|
|
@@ -970,9 +970,11 @@ impl<'src> TokenizeCtx<'src> {
|
|
|
970
970
|
seen_quotes += 1;
|
|
971
971
|
|
|
972
972
|
if seen_quotes == ending_char_count {
|
|
973
|
-
|
|
973
|
+
// Use ending_marker for the span/slice end position, not current cursor,
|
|
974
|
+
// because we may have consumed some ending quotes already
|
|
975
|
+
let span = Span::new(marker..ending_marker);
|
|
974
976
|
tokens.push(SToken::new(
|
|
975
|
-
Token::FstrInner(self.
|
|
977
|
+
Token::FstrInner(&self.input[marker..ending_marker], current_str),
|
|
976
978
|
span,
|
|
977
979
|
Vec::new(),
|
|
978
980
|
));
|
|
@@ -84,16 +84,20 @@ export Iterable = class(Traversable, Trait):
|
|
|
84
84
|
|
|
85
85
|
impl()
|
|
86
86
|
|
|
87
|
-
flat_map = (self, f) =>
|
|
87
|
+
flat_map = (self, f=None) =>
|
|
88
|
+
if f === None:
|
|
89
|
+
itertools.chain.from_iterable(self.iter)
|
|
90
|
+
else:
|
|
91
|
+
itertools.chain.from_iterable(self.iter.map(f))
|
|
88
92
|
|
|
89
|
-
|
|
93
|
+
reversed = self => reversed(list(self.iter))
|
|
90
94
|
|
|
91
|
-
|
|
95
|
+
sorted = (self, key=None, reverse=False) =>
|
|
92
96
|
sorted(self.iter, key=key, reverse=reverse)
|
|
93
97
|
|
|
94
98
|
copy = self => itertools.tee(self.iter)
|
|
95
99
|
|
|
96
|
-
|
|
100
|
+
tally = (self, f=None) =>
|
|
97
101
|
let acc = 0
|
|
98
102
|
if f === None:
|
|
99
103
|
for _ in self:
|
|
@@ -187,7 +191,7 @@ export Iterable = class(Traversable, Trait):
|
|
|
187
191
|
impl()
|
|
188
192
|
|
|
189
193
|
join = (self, sep="") =>
|
|
190
|
-
sep.join(self.map(str))
|
|
194
|
+
sep.join(self.iter.map(str))
|
|
191
195
|
|
|
192
196
|
sum = self =>
|
|
193
197
|
let acc = 0
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import util.assert_eq
|
|
2
|
-
|
|
3
|
-
assert_eq(f"{1}", "1")
|
|
4
|
-
|
|
5
|
-
x = 1
|
|
6
|
-
|
|
7
|
-
fstr = f"x = {x+1}"
|
|
8
|
-
assert_eq(fstr, "x = 2")
|
|
9
|
-
|
|
10
|
-
fstr = f"x = {(y => y)(x)}"
|
|
11
|
-
assert_eq(fstr, "x = 1")
|
|
12
|
-
|
|
13
|
-
fstr = f"={(
|
|
14
|
-
let a = 1
|
|
15
|
-
let b = 2
|
|
16
|
-
let c = 3
|
|
17
|
-
a * b * c
|
|
18
|
-
)}="
|
|
19
|
-
assert_eq(fstr, "=6=")
|
|
20
|
-
|
|
21
|
-
assert_eq(f"{{}}", "{}")
|
|
22
|
-
assert_eq(f"{{{1}}}", "{1}")
|
|
23
|
-
|
|
24
|
-
assert_eq(f"""
|
|
25
|
-
|
|
26
|
-
{{1}}
|
|
27
|
-
{2 * 5}""", "\n\n{1}\n10")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|