<commit_before>import { expect } from "chai";
import { Frame, FrameArg, FrameExpr, FrameString } from "../../src/frames";

describe("FrameExpr", () => {
  const frame = new Frame();
  const js_string = "Hello";
  const context = new FrameString("context");
  const frame_string = new FrameString(js_string);
  const frame_expr = new FrameExpr([frame, frame_string], {context: context});

  it("stringifies with parentheses", () => {
    expect(frame_expr.toString()).to.equal(`(() “${js_string}”, .context “context”;)`);
  });

  it("replaces nil when evaluated", () => {
    const result = frame_expr.in(frame);
    expect(result).to.equal(frame_string);
  });

  it("concatenates string expressions when called", () => {
    const js_string_2 = ", MAML!";
    const frame_string_2 = new FrameString(js_string_2);
    const frame_expr_2 = new FrameExpr([frame_string, frame_string_2]);
    const result = frame_expr_2.in(frame);

    expect(result.toString()).to.equal(`“${js_string}${js_string_2}”`);
  });

  it("returns context for FrameArg.here", () => {
    const context = new FrameString("context", {key: frame_string});
    const frame_expr = new FrameExpr([FrameArg.here()]);
    const result = frame_expr.in(context);

    expect(result).to.equal(context);
  });

  it("extracts properties from the context", () => {
    const context = new FrameString("context", {key: frame_string});
    const frame_expr = FrameExpr.extract("key");
    const result = frame_expr.in(context);

    expect(result).to.equal(frame_string);
  });

  it("evaluates in context when called", () => {
    const context = new FrameString("context", {key: frame_string});
    const frame_expr = FrameExpr.extract("key");
    const result = frame_expr.call(context);

    expect(result).to.equal(frame_string);
  });

});<commit_msg>Discovered new Expr failure mode<commit_after>import { expect } from "chai";
import { Frame, FrameArg, FrameExpr, FrameString, FrameSymbol } from "../../src/frames";

describe("FrameExpr", () => {
  const frame = new Frame();
  const js_string = "Hello";
  const context = new FrameString("context");
  const frame_string = new FrameString(js_string);
  const frame_expr = new FrameExpr([frame, frame_string], {context: context});

  it("stringifies with parentheses", () => {
    expect(frame_expr.toString()).to.equal(`(() “${js_string}”, .context “context”;)`);
  });

  it("replaces nil when evaluated", () => {
    const result = frame_expr.in(frame);
    expect(result).to.equal(frame_string);
  });

  it("concatenates string expressions when called", () => {
    const js_string_2 = ", MAML!";
    const frame_string_2 = new FrameString(js_string_2);
    const frame_expr_2 = new FrameExpr([frame_string, frame_string_2]);
    const result = frame_expr_2.in(frame);

    expect(result.toString()).to.equal(`“${js_string}${js_string_2}”`);
  });

  it("returns context for FrameArg.here", () => {
    const context = new FrameString("context", {key: frame_string});
    const frame_expr = new FrameExpr([FrameArg.here()]);
    const result = frame_expr.in(context);

    expect(result).to.equal(context);
  });

  it("extracts properties from the context", () => {
    const context = new FrameString("context", {key: frame_string});
    const frame_expr = FrameExpr.extract("key");
    const result = frame_expr.in(context);

    expect(result).to.equal(frame_string);
  });

  it("evaluates in context when called", () => {
    const context = new FrameString("context", {key: frame_string});
    const frame_expr = FrameExpr.extract("key");
    const result = frame_expr.call(context);

    expect(result).to.equal(frame_string);
  });

  it("evaluates a sequence of properties", () => {
    const slow = new FrameString("slow");
    const space = new FrameString(" ");
    const turtle = new FrameString("turtle");

    const lazy_array = [new FrameSymbol("speed"), new FrameSymbol("gap"), FrameArg.here()];
    const frame_expr = new FrameExpr(lazy_array, {speed: slow, gap: space});

    expect(frame_expr.call(turtle).toString()).to.equal(`“slow turtle”`);
  });
});
{'fraction_non_alphanumeric': 0.16764275256222547, 'fraction_numerical': 0.003416300634455832, 'mean_word_length': 4.472630173564753, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5425546', 'n_tokens_mistral': 1276, 'n_tokens_neox': 1238, 'n_words': 287}