Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion quest/m3/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ generic std gap is planned here even when moq never calls it.
- [Set operations](/quest/m3/ts-set-ops.md) - `union`, `intersection`, `difference`, and `symmetric_difference` of hash and B-tree sets translate
- [References to byte arrays std takes](/quest/m3/ts-byte-refs-taken.md) - `extend` by references to arrays, adaptors' closures over held arrays, and a collection of both forms translate
- [Size hints of std's iterators](/quest/m3/ts-size-hints.md) - `size_hint` translates, and `Vec`'s collect and extend panic past `isize::MAX` as std's do
- [Peekable::next_if_eq against another type](/quest/m3/ts-next-if-eq-other.md) - `next_if_eq` with an expected value of another type than the item, such as a `&str` of `String` items, translates
- [A closure's () result as a value](/quest/m3/ts-unit-closures.md) - a closure returning `()` whose result is a value, as in a `Vec<()>` collected from `map`, type-checks
- [std accessors with no mapping](/quest/m3/ts-unmapped-accessors.md) - `VecDeque::swap_remove_*`, `HashSet::replace`, `BTreeSet::get`, `take`, and `replace`, `Vec::pop_if`, and `Arc` and `Rc::into_inner` translate
- [Equality of std containers of unlike elements](/quest/m3/ts-eq-unlike.md) - `==` and `next_if_eq` of a `Vec<Left>` against a `&[Right]`, and of `VecDeque` against `Vec`, translate
- [Integers' little- and native-endian bytes](/quest/m3/ts-int-ne-bytes.md) - each integer's `from_le_bytes`, `to_ne_bytes`, and `from_ne_bytes` translate
- [mul_add rounded once](/quest/m3/ts-mul-add.md) - `f64::mul_add` and `f32::mul_add` translate, rounding once as std's fused multiply-add does
- [Waiting: a slice object for a mutable part of other values](/quest/m3/ts-slice-object.md) - waits on a moq profile showing the `Proxy` view's traps matter, then decides on an `rt.ByteSlice`-like form
Expand Down
18 changes: 18 additions & 0 deletions quest/m3/ts-eq-unlike.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# [S] Equality of std containers of unlike elements

## Goal

`==` and `next_if_eq` of std containers whose elements are of other types that compare
by their own `PartialEq<U>`, as a `Vec<Left>` against a `&[Right]` does, and of
`VecDeque` against `Vec`, slices, and arrays, translate, proven by a differential test
against native Rust.

## Plan

Refused at their spans today, as the reject fixture's `unlike_elements` and
`peeked_deque` are: the collections mapping compares only containers whose elements
compare alike. Each element pair could lower through `<T as PartialEq<U>>::eq` as
`next_if_eq` of other types does, lending a `[u8; N]` element as its `rt.ByteSlice`, with
`ne` by the elements' own `ne` where a crate overrides it.

Public API: the translator's output.
15 changes: 0 additions & 15 deletions quest/m3/ts-next-if-eq-other.md

This file was deleted.

10 changes: 9 additions & 1 deletion ts/fixtures/lang/caller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,14 @@ const ranges = [0, 1, 2, 3, 4].flatMap((n) => {
*/
const reducers = [[], [9], [9, 9], [8, 4, 12, 0x40, 0x80]].map((bytes) => Uint8Array.of(op("iters::reducers"), 0, ...bytes));

/**
* `iters::peeked_others` of no items, one, a run that matches the first throughout, and
* items that each match one comparison and miss the next.
*/
const peekedOthers = [[], [3], [4, 4, 4, 4], [0, 1, 2, 3, 4, 5, 6], [1, 0, 0, 2, 5, 9]].map((bytes) =>
Uint8Array.of(op("iters::peeked_others"), 0, ...bytes),
);

/**
* `edits` of each kind over zero to four items, at every three bounds up to one past the
* end, so parts are empty, at the end, backwards, and out of bounds.
Expand Down Expand Up @@ -476,4 +484,4 @@ const iters = Array.from({ length: 12 }, (_, kind) => [[], [2, 7, 9, 14], [0, 2,
const hintedOp = op("strs::hinted");
const hinted = Array.from({ length: 10 * 7 * 21 }, (_, i) => Uint8Array.of(hintedOp, i % 10, Math.floor(i / 10) % 7, Math.floor(i / 70)));

export const cases: Uint8Array[] = [...loops, ...durations, ...ints(), ...utf8, ...floats, ...formats, ...parsed, ...singlesCases, ...singlesFormats, ...singlesParsed, ...dyns, ...cells, ...shared, ...locks, ...onces, ...bounds, ...unsafeCells, ...edits, ...subslices, ...consumers, ...closures, ...elements, ...ranges, ...reducers, ...sliceEdits, ...drains, ...iters, ...hinted];
export const cases: Uint8Array[] = [...loops, ...durations, ...ints(), ...utf8, ...floats, ...formats, ...parsed, ...singlesCases, ...singlesFormats, ...singlesParsed, ...dyns, ...cells, ...shared, ...locks, ...onces, ...bounds, ...unsafeCells, ...edits, ...subslices, ...consumers, ...closures, ...elements, ...ranges, ...reducers, ...sliceEdits, ...drains, ...iters, ...hinted, ...peekedOthers];
34 changes: 31 additions & 3 deletions ts/fixtures/lang/expected/core/option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import type * as Twin from "../counts.Twin.ts";
import * as Made from "../defaults.Made.ts";
import type * as Shape from "../dyns.Shape.ts";
import * as Named from "../edits.Named.ts";
import type * as Quarter from "../iters.Quarter.ts";
import type * as Tilt from "../iters.Tilt.ts";
import { side, order } from "../keys.ts";
import type * as Hop from "../keys.Hop.ts";
Expand Down Expand Up @@ -239,6 +240,13 @@ export function map$0xa0bn7(self: Named.Named | undefined, f: (a0: Named.Named)
return f(self);
}

export function map$1uo1d4o(self: string | undefined, _: (a0: string) => string): string | undefined {
if (self === undefined) {
return undefined;
}
return self;
}

export function map$0600mq0(self: Dir.Dir | undefined, f: (a0: Dir.Dir) => shapes_Shape.Shape): shapes_Shape.Shape | undefined {
if (self === undefined) {
return undefined;
Expand Down Expand Up @@ -317,18 +325,18 @@ export function map$11y9s7r(self: slices_Pair.Pair[] | undefined, f: (a0: slices
return f(self);
}

export function map$0lcwx9x(self: Way.Way | undefined, f: (a0: Way.Way) => boolean): boolean | undefined {
export function map$1httady(self: string[] | undefined, f: (a0: string[]) => string): string | undefined {
if (self === undefined) {
return undefined;
}
return f(self);
}

export function map$1uo1d4o(self: string | undefined, _: (a0: string) => string): string | undefined {
export function map$0lcwx9x(self: Way.Way | undefined, f: (a0: Way.Way) => boolean): boolean | undefined {
if (self === undefined) {
return undefined;
}
return self;
return f(self);
}

export function map$0qyyft9(self: rt.u16[] | undefined, _: (a0: rt.u16[]) => rt.u8): rt.u8 | undefined {
Expand Down Expand Up @@ -604,6 +612,13 @@ export function mapOr$0rtdylj(self: Point.Point | undefined, default_: rt.u8, f:
return f(self);
}

export function mapOr$1lznlgz(self: Quarter.Quarter | undefined, default_: rt.u8, f: (a0: Quarter.Quarter) => rt.u8): rt.u8 {
if (self === undefined) {
return default_;
}
return f(self);
}

export function mapOr$1to2ul4(self: [Rank.Rank, Tally.Tally] | undefined, default_: rt.u8, f: (a0: [Rank.Rank, Tally.Tally]) => rt.u8): rt.u8 {
if (self === undefined) {
return default_;
Expand Down Expand Up @@ -744,6 +759,13 @@ export function mapOr$1surhce(self: rt.u8 | undefined, default_: rt.u8, f: (a0:
return f(self);
}

export function mapOr$0ev76sb(self: rt.Place<rt.u8> | undefined, default_: rt.u8, f: (a0: rt.Place<rt.u8>) => rt.u8): rt.u8 {
if (self === undefined) {
return default_;
}
return f(self);
}

export function mapOr$0mmpeqx(self: [rt.u8, rt.u8] | undefined, default_: rt.u8, f: (a0: [rt.u8, rt.u8]) => rt.u8): rt.u8 {
if (self === undefined) {
return default_;
Expand Down Expand Up @@ -917,6 +939,12 @@ export function asDeref$0s3650c(self: rt.Arc<rt.u8> | undefined): rt.u8 | undefi
});
}

export function asDeref$0w8at8i(self: string | undefined): string | undefined {
return map$1uo1d4o(self, (a0: string): string => {
return a0;
});
}

export function and$06om98g(self: rt.u8 | undefined, optb: rt.u8 | undefined): rt.u8 | undefined {
if (self === undefined) {
return undefined;
Expand Down
6 changes: 4 additions & 2 deletions ts/fixtures/lang/expected/harness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { methods } from "./generics.ts";
import { values, random, bytes as hashes_bytes } from "./hashes.ts";
import { holds } from "./holds.ts";
import { u8Op, u16Op, u32Op, u64Op, u128Op, usizeOp, i8Op, i16Op, i32Op, i64Op, i128Op, isizeOp, i8Neg, i16Neg, i32Neg, i64Neg, i128Neg, isizeNeg, cast as ints_cast, convert, parses as ints_parses, widenings } from "./ints.ts";
import { adaptors, consumers, reducers, skips, ranked, ranges, options, own, values as iters_values, returned } from "./iters.ts";
import { adaptors, consumers, reducers, peekedOthers, skips, ranked, ranges, options, own, values as iters_values, returned } from "./iters.ts";
import { keys, overrides, bytes as keys_bytes, lentKeys, lentValues } from "./keys.ts";
import { locals } from "./locals.ts";
import { locks, relock, rwlocks } from "./locks.ts";
Expand Down Expand Up @@ -183,7 +183,9 @@ export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec)
asSlices(data66, out67);
}] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["ints::widenings", widenings] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["shapes::uninhabited", (_2167: rt.u8, data67: rt.ByteSlice, out68: rt.ByteVec): void => {
uninhabited(data67, out68);
}] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["keys::lent_keys", lentKeys] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["keys::lent_values", lentValues] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["singles::singles", singles] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["singles::formats", singles_formats] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["singles::parses", singles_parses] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void]];
}] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["keys::lent_keys", lentKeys] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["keys::lent_values", lentValues] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["singles::singles", singles] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["singles::formats", singles_formats] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["singles::parses", singles_parses] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["iters::peeked_others", (_2168: rt.u8, data68: rt.ByteSlice, out69: rt.ByteVec): void => {
peekedOthers(data68, out69);
}] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void]];
}

/** Run one case. */
Expand Down
16 changes: 16 additions & 0 deletions ts/fixtures/lang/expected/iters.Quarter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Generated by rust2-ts. Do not edit.

import * as rt from "./rt.ts";

/** A byte that equals a `u8` of the same remainder by 4, counting each comparison. */
export interface Quarter {
_0: rt.u8;
_1: rt.Cell<rt.u8>;
}

export function eq$PartialEq_u8(self: Quarter, other: rt.u8): boolean {
rt.cellSet(self._1, rt.u8WrappingAdd(self._1.v, 1));
return rt.u8Rem(self._0, 4) === rt.u8Rem(other, 4);
}

//# sourceMappingURL=iters.Quarter.ts.map
Loading