Skip to content

feat: add 15 Funge-98 fingerprints and fix test assertion argument order#8

Merged
juner merged 8 commits into
feature/fingerprintsfrom
copilot/featurefingerprints
Jun 12, 2026
Merged

feat: add 15 Funge-98 fingerprints and fix test assertion argument order#8
juner merged 8 commits into
feature/fingerprintsfrom
copilot/featurefingerprints

Conversation

Copilot AI commented Jun 11, 2026

Copy link
Copy Markdown

Implements 15 missing Funge-98 fingerprints and fixes test failures caused by reversed Assert argument order in EVAR and HRTI test suites.

New Fingerprints

  • 3DSP (0x33445350) — 3D space operations: vector math, matrix transforms (A B C D L M N P R S T U V X Y Z)
  • CPLI (0x43504C49) — complex integer arithmetic (A D M O S V)
  • DIRF (0x44495246) — directory operations: make/change/remove (C M R)
  • EVAR (0x45564152) — environment variable get/set/enumerate (G N P V)
  • FPDP (0x46504450) — double-precision float math (A B C D E F G H I K L M N P Q S T V X Y)
  • FPRT (0x46505254) — formatted print for numeric and string types (D F I L S)
  • FPSP (0x46505350) — single-precision float math, same instruction set as FPDP
  • HRTI (0x48525449) — high-resolution timer: mark/measure per IP (E G M S T)
  • ICAL (0x4943414C) — INTERCAL-style bitwise ops and thread control (A F I N O R S X)
  • JSTR (0x4A535452) — jump-relative string get/put (G P)
  • ORTH (0x4F525448) — Orthagonal-mode cell I/O and IP control (A E G O P S V W X Y Z)
  • REFC (0x52454643) — vector reference storage (D R)
  • SETS (0x53455453) — integer set operations (A C D G I M P R S U W X Z)
  • TERM (0x5445524D) — ANSI terminal cursor/screen control (C D G H L S U)
  • TOYS (0x544F5953) — full A–Z toybox: space fill/copy/shift, stack arithmetic, directional helpers

All fingerprints registered in FingerprintsOptions and Esolang.Funge.slnx. README.md fingerprint table and CHANGELOG.md updated accordingly.

Test Fixes (EVAR & HRTI)

MSTest v3 assertion methods take (lowerBound, value) / (upperBound, value) — the second argument is the value under test. Several assertions had the arguments reversed, causing spurious failures despite correct implementations:

// ❌ Before — asserts 0 > count (always fails when count > 0)
Assert.IsGreaterThan(ctx.Pop(), 0);

// ✅ After — asserts count > 0
Assert.IsGreaterThan(0, ctx.Pop());

Same inversion corrected for IsGreaterThanOrEqualTo (HRTI elapsed time, granularity, cloned mark) and IsLessThan (microsecond upper-bound check).

Original prompt

Task

Implement the PyFunge fingerprints (https://pythonhosted.org/PyFunge/languages.html#supported-fingerprints) not yet in this repo on top of the feature/fingerprints branch. Read AGENT.md and existing fingerprints (e.g. Fingerprints.Roma/, Fingerprints.Strn/, Fingerprints.Time/) before starting.

Already implemented (do not re-implement)

NULL, ARRY, BASE, BOOL, DATE, FILE, FIXP, FRTH, IMTH, INDV, LONG, MODU, RAND, ROMA, STCK, STRN, TIME

Fingerprints to implement (15 total)

For each fingerprint, create: library project + source file + README.md, test project + test file, and register in Interpreter/FingerprintsOptions.cs. Also update Esolang.Funge.slnx, README.md, CHANGELOG.md.

Follow the same project structure as existing fingerprints (see Fingerprints.Roma/ as the simplest template). All projects target netstandard2.0;netstandard2.1;net10.0. Test projects target net48;net8.0;net9.0;net10.0 on Windows, net8.0;net9.0;net10.0 on other OSes.

New abstraction interface needed

Add Abstractions/IFungePositionContext.cs (needed by ORTH, TOYS, ICAL):

namespace Esolang.Funge;
public interface IFungePositionContext
{
    (int X, int Y, int Z) Position { get; set; }
    (int X, int Y, int Z) Delta { get; set; }
}

Available optional capability interfaces (check with ctx is IFoo foo, reflect if missing)

  • IFungeOutputContext: WriteString(string)
  • IFungeInputContext: ReadLine()
  • IFungeVectorContext: PopVector()→(X,Y,Z), PushVector(x,y,z)
  • IFungeSpaceContext: Dimensions, GetCell(x,y,z), SetCell(x,y,z,value)
  • IFungeStorageOffsetContext: StorageOffset→(X,Y,Z)
  • IFungeStackContext: StackDepth
  • IFungeInstructionPointerContext: InstructionPointerId
  • IFungeInstructionPointerLifecycle: OnInstructionPointerCloned, OnInstructionPointerTerminated
  • IFungeRandomContext (see Rand fingerprint)
  • IFungePositionContext (new, add to Abstractions)

0gnirts helper pattern (copy from STRN)

Pop: read chars until 0. Push: push 0 then chars left-to-right.

FPSP bit encoding

BitConverter.SingleToInt32Bits(float) / Int32BitsToSingle(int) — one cell per float.

FPDP bit encoding

Two cells: push lower 32 bits first, upper 32 bits second. Pop upper first, then lower.


Fingerprint Specifications

1. DIRF (0x44495246) — Directory functions

Namespace: Esolang.Funge.Fingerprints.Dirf, Class: DirectoryFingerprint
Ref: https://pythonhosted.org/PyFunge/fingerprint/DIRF.html

  • C: pop path_s → Directory.SetCurrentDirectory; reflect on exception
  • M: pop path_s → Directory.CreateDirectory; reflect on exception
  • R: pop path_s → Directory.Delete; reflect on exception

2. TERM (0x5445524D) — Terminal extension

Namespace: Esolang.Funge.Fingerprints.Term, Class: TerminalFingerprint
Ref: https://pythonhosted.org/PyFunge/fingerprint/TERM.html
Uses ANSI escapes via IFungeOutputContext (reflect if unavailable):

  • C: WriteString("\x1b[2J")
  • H: WriteString("\x1b[H")
  • G: pop c, pop r → WriteString($"\x1b[{r+1};{c+1}H")
  • D: pop n → n>0: "\x1b[{n}B", n<0: "\x1b[{-n}A", n==0: no-op
  • U: pop n → n>0: "\x1b[{n}A", n<0: "\x1b[{-n}B", n==0: no-op
  • L: WriteString("\x1b[K")
  • S: WriteString("\x1b[J")

3. REFC (0x52454643) — Referenced Cells Extension

Namespace: Esolang.Funge.Fingerprints.Refc, Class: ReferencedCellsFingerprint
Ref: https://pythonhosted.org/PyFunge/fingerprint/REFC.html
Global table (shared across IPs): Dictionary<int,( int X,int Y,int Z)>, auto-increment ref.

  • R: pop vector_v (PopVector()) → store; push new ref int
  • D: pop ref → PushVector stored vector; reflect if invalid
    Reflect if IFungeVectorContext unavailable.

4. CPLI (0x43504C49) — Complex Integer extension

Namespace: Esolang.Funge.Fingerprints.Cpli, Class: ComplexIntegerFingerprint
Ref: https://pythonhosted.org/PyFunge/fingerprint/CPLI.html
Stack layout: real (lower), imag (upper). For binary: pop d(imag2), c(real2), b(imag1), a(real1). Push result real then imag.

  • A: (a+bi)+(c+di) → push (a+c), (b+d)
  • S: (a+bi)-(c+di) → push (a-c), (b-d)
  • M: (a+bi)*(c+di) → push (ac-bd), (ad+bc)
  • D: (a+bi)/(c+di) truncated; reflect if c==0&&d==0. r=(ac+bd)/(cc+dd), i=(bc-ad)/(cc+dd)
  • O: pop b(imag), pop a(real) → print via IFungeOutputContext; reflect if unavailable
  • V: pop b, pop a → push (int)Math.Sqrt(aa+bb)

5. EVAR (0x45564152) — Environment variables extension

Namespace: Esolang.Funge.Fingerprints.Evar, Class: EnvironmentVariablesFingerprint
Ref: https://pythonhosted.org/PyFunge/fingerprint/EVAR.html

  • G: pop name_s → push value_s (empty string if not found)
  • N: push Environment.GetEnvironmentVariables().Count
  • P: pop namevalue_s (format "name=value") → setenv; reflect if no '='
  • V: pop i → push i-th env var sorted by key as "name=value" 0gnirts; reflect if out of range

6. HRTI (0x48525449) — High-Resolution Timer Interface

Namespace: Esolang.Funge.Fingerprints.Hrti, Class: `HighResTim...

Copilot AI changed the title [WIP] Implement remaining PyFunge fingerprints Implement 15 PyFunge fingerprints on feature/fingerprints branch Jun 11, 2026
Copilot AI requested a review from juner June 11, 2026 16:57
Copilot finished work on behalf of juner June 11, 2026 16:57
@juner

juner commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

@copilot dotnet test は実施されましたでしょうか? 現在下記のテストでNGが出ています。
対応宜しくお願いします。 もしも 仕様に修正が必要であれば pyfunge ではなく esolang wiki や 元となる archive の資料も参照して README.md に追記して修正してください。

  • Fingerprints.Evar.Tests
    • Instruction_N_PushesCount (net48 / net8.0 / net9.0 / net10.0)
  • Fingerprints.Hrti.Tests
    • Instruction_M_T_MeasuresElapsed (net48 / net8.0 / net9.0 / net10.0)
    • Instruction_S_PushesSecondMicroseconds (net48 / net8.0 / net9.0 / net10.0)
    • OnCloned_CopiesMarkToChild (net48 / net8.0 / net9.0 / net10.0)

Copilot AI changed the title Implement 15 PyFunge fingerprints on feature/fingerprints branch feat: add 15 new fingerprints (3DSP, CPLI, DIRF, EVAR, FPDP, FPRT, FPSP, HRTI, ICAL, JSTR, ORTH, REFC, SETS, TERM, TOYS) Jun 12, 2026
Copilot finished work on behalf of juner June 12, 2026 00:48
Copilot AI changed the title feat: add 15 new fingerprints (3DSP, CPLI, DIRF, EVAR, FPDP, FPRT, FPSP, HRTI, ICAL, JSTR, ORTH, REFC, SETS, TERM, TOYS) feat: add 15 Funge-98 fingerprints and fix test assertion argument order Jun 12, 2026
Copilot finished work on behalf of juner June 12, 2026 00:59
@juner juner marked this pull request as ready for review June 12, 2026 01:33
@juner juner merged commit c953746 into feature/fingerprints Jun 12, 2026
3 checks passed
@juner juner deleted the copilot/featurefingerprints branch June 12, 2026 01:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants