/** * Synthetic fixture source code for each tier-1 language. * * Public-repo policy (#1551): every fixture is synthetic — never real user * code. Each fixture is small enough that the expected IR can be reasoned * about and asserted against without magic numbers. */ import type { CodingGraphLanguage } from "@remnic/core"; export interface Fixture { /** Repository-relative path (used for language sniffing + IR output). */ readonly path: string; /** Synthetic source code (UTF-8). */ readonly code: string; } export const FIXTURES: Record = { typescript: { path: "src/app.ts", code: [ 'import { Router } from "express";', "import type { Config } from './types';", "", "export interface AppOptions {", " port: number;", "}", "", "export type Mode = 'dev' | 'prod';", "", "export class Server {", " private router: Router;", "", " constructor(router: Router) {", " this.router = router;", " }", "", " public start(): void {", " this.router.get('/', () => {});", " }", "}", "", "export function createServer(opts: AppOptions): Server {", " const r = new Router();", " return new Server(r);", "}", "", "const app = createServer({ port: 3000 });", ].join("\n"), }, tsx: { path: "src/component.tsx", code: [ 'import React, { useState } from "react";', "", "export interface ButtonProps {", " label: string;", " onClick: () => void;", "}", "", "export function Button(props: ButtonProps) {", " const [clicked, setClicked] = useState(false);", " return null;", "}", "", "export const Container = () => {", " return null;", "};", ].join("\n"), }, javascript: { path: "lib/router.js", code: [ 'const express = require("express");', "", "function createRouter() {", " const router = express.Router();", " router.get('/health', function healthCheck(req, res) {});", " return router;", "}", "", "class App {", " constructor() {", " this.router = createRouter();", " }", "}", "", "module.exports = { App, createRouter };", ].join("\n"), }, python: { path: "app/models.py", code: [ "from typing import List", "from dataclasses import dataclass", "", "class User:", " def __init__(self, name):", " self.name = name", "", " def greet(self):", " return format_name(self.name)", "", "def format_name(name):", " return name.strip()", "", "def main():", " user = User('alice')", " print(user.greet())", ].join("\n"), }, go: { path: "cmd/server/main.go", code: [ "package main", "", 'import "fmt"', "", "type Server struct {", " Addr string", "}", "", "func main() {", ' s := Server{Addr: ":8080"}', " fmt.Println(s.Addr)", "}", "", "func (s *Server) Start() error {", " return nil", "}", ].join("\n"), }, rust: { path: "src/lib.rs", code: [ "use std::collections::HashMap;", "", "pub fn add(a: i32, b: i32) -> i32 {", " a + b", "}", "", "pub struct Config {", " pub port: u16,", "}", "", "impl Config {", " pub fn new() -> Self {", " Self { port: 8080 }", " }", "}", "", "pub trait Service {", " fn run(&self) -> bool;", "}", ].join("\n"), }, java: { path: "src/main/Server.java", code: [ "package com.example;", "", "import java.util.List;", "", "public class Server {", " private String name;", "", " public void start() {", " System.out.println(name);", " }", "", " protected static int compute() {", " return 0;", " }", "}", "", "interface Handler {", " void handle();", "}", ].join("\n"), }, c: { path: "src/main.c", code: [ "#include ", "#include ", "", "typedef struct {", " int x;", " int y;", "} Point;", "", "int add(int a, int b) {", " return a + b;", "}", "", "void main_loop(void) {", " int sum = add(1, 2);", " printf(\"%d\\n\", sum);", "}", ].join("\n"), }, cpp: { path: "src/engine.cpp", code: [ "#include ", "#include ", "", "namespace engine {", "", "class Widget {", "public:", " void render();", " int getWidth() { return width_; }", "private:", " int width_;", "};", "", "int compute_total(int count) {", " return count * 2;", "}", "", "} // namespace engine", ].join("\n"), }, csharp: { path: "src/Server.cs", code: [ "using System;", "using System.Collections.Generic;", "", "namespace MyApp {", " public class Server {", " public void Start() {", " Console.WriteLine(\"started\");", " }", " private static int Compute() {", " return 42;", " }", " }", "", " interface IService {", " void Run();", " }", "}", ].join("\n"), }, ruby: { path: "lib/app.rb", code: [ 'require "json"', "", "class User", " def initialize(name)", " @name = name", " end", "", " def greet", " format_name(@name)", " end", "end", "", "module Auth", " def login", " true", " end", "end", ].join("\n"), }, php: { path: "src/Order.php", code: [ "total();", "}", ].join("\n"), }, kotlin: { path: "src/main/kotlin/Server.kt", code: [ "package com.example", "", "import kotlin.collections.*", "", "class Server(val port: Int) {", " fun start() {", " println(port)", " }", "}", "", "object Singleton {", " val count = 0", "}", "", "fun create(): Server {", " return Server(8080)", "}", ].join("\n"), }, swift: { path: "Sources/App.swift", code: [ "import Foundation", "", "class View {", " func render() {", " print(\"rendering\")", " }", "}", "", "protocol Drawable {", " func draw()", "}", "", "func main() {", " let view = View()", " view.render()", "}", ].join("\n"), }, bash: { path: "scripts/deploy.sh", code: [ "#!/bin/bash", "", "function deploy() {", " echo \"deploying\"", " rsync -avz dist/ server:/app/", "}", "", "function rollback() {", " echo \"rolling back\"", " return 0", "}", ].join("\n"), }, };