Brunobkr/llama.cpp_AlgMor24_github
ΩFFFΣLLIa • llama.cpp • AlgMor24 ██████╗ ███████╗███████╗███████╗██╗ ██╗ ██╗ █████╗ ██╔═══██╗██╔════╝██╔════╝██╔════╝██║ ██║ ██║██╔══██╗ ██║ ██║█████╗ █████╗ █████╗ ██║ ██║ ██║███████║ ██║ ██║██╔══╝ ██╔══╝ ██╔══╝ ██║ ██║ ██║██╔══██║ ╚██████╔╝██║ ██║ ███████╗███████╗███████╗██║██║ ██║ ╚═════╝ ╚═╝ ╚═╝ ╚══════╝╚══════╝╚══════╝╚═╝╚═╝ ╚═╝ High-Performance LLM / VLM Inference & Autonomous Agentic Ecosystem… See the full description on the dataset page: https://huggingface.co/datasets/Brunobkr/llama.cpp_AlgMor24_github.
03.1k
1// @ts-ignore TS61332import { expect, test } from "vitest";3 4import * as z from "zod/v3";5import { util } from "../helpers/util.js";6 7const fish = z.object({8 name: z.string(),9 age: z.number(),10 nested: z.object({}),11});12 13test("pick type inference", () => {14 const nameonlyFish = fish.pick({ name: true });15 type nameonlyFish = z.infer<typeof nameonlyFish>;16 util.assertEqual<nameonlyFish, { name: string }>(true);17});18 19test("pick parse - success", () => {20 const nameonlyFish = fish.pick({ name: true });21 nameonlyFish.parse({ name: "bob" });22 23 // @ts-expect-error checking runtime picks `name` only.24 const anotherNameonlyFish = fish.pick({ name: true, age: false });25 anotherNameonlyFish.parse({ name: "bob" });26});27 28test("pick parse - fail", () => {29 fish.pick({ name: true }).parse({ name: "12" } as any);30 fish.pick({ name: true }).parse({ name: "bob", age: 12 } as any);31 fish.pick({ age: true }).parse({ age: 12 } as any);32 33 const nameonlyFish = fish.pick({ name: true }).strict();34 const bad1 = () => nameonlyFish.parse({ name: 12 } as any);35 const bad2 = () => nameonlyFish.parse({ name: "bob", age: 12 } as any);36 const bad3 = () => nameonlyFish.parse({ age: 12 } as any);37 38 // @ts-expect-error checking runtime picks `name` only.39 const anotherNameonlyFish = fish.pick({ name: true, age: false }).strict();40 const bad4 = () => anotherNameonlyFish.parse({ name: "bob", age: 12 } as any);41 42 expect(bad1).toThrow();43 expect(bad2).toThrow();44 expect(bad3).toThrow();45 expect(bad4).toThrow();46});47 48test("omit type inference", () => {49 const nonameFish = fish.omit({ name: true });50 type nonameFish = z.infer<typeof nonameFish>;51 util.assertEqual<nonameFish, { age: number; nested: {} }>(true);52});53 54test("omit parse - success", () => {55 const nonameFish = fish.omit({ name: true });56 nonameFish.parse({ age: 12, nested: {} });57 58 // @ts-expect-error checking runtime omits `name` only.59 const anotherNonameFish = fish.omit({ name: true, age: false });60 anotherNonameFish.parse({ age: 12, nested: {} });61});62 63test("omit parse - fail", () => {64 const nonameFish = fish.omit({ name: true });65 const bad1 = () => nonameFish.parse({ name: 12 } as any);66 const bad2 = () => nonameFish.parse({ age: 12 } as any);67 const bad3 = () => nonameFish.parse({} as any);68 69 // @ts-expect-error checking runtime omits `name` only.70 const anotherNonameFish = fish.omit({ name: true, age: false });71 const bad4 = () => anotherNonameFish.parse({ nested: {} } as any);72 73 expect(bad1).toThrow();74 expect(bad2).toThrow();75 expect(bad3).toThrow();76 expect(bad4).toThrow();77});78 79test("nonstrict inference", () => {80 const laxfish = fish.pick({ name: true }).catchall(z.any());81 type laxfish = z.infer<typeof laxfish>;82 util.assertEqual<laxfish, { name: string } & { [k: string]: any }>(true);83});84 85test("nonstrict parsing - pass", () => {86 const laxfish = fish.passthrough().pick({ name: true });87 laxfish.parse({ name: "asdf", whatever: "asdf" });88 laxfish.parse({ name: "asdf", age: 12, nested: {} });89});90 91test("nonstrict parsing - fail", () => {92 const laxfish = fish.passthrough().pick({ name: true });93 const bad = () => laxfish.parse({ whatever: "asdf" } as any);94 expect(bad).toThrow();95});96 97test("pick/omit/required/partial - do not allow unknown keys", () => {98 const schema = z.object({99 name: z.string(),100 age: z.number(),101 });102 103 // @ts-expect-error104 schema.pick({ $unknown: true });105 // @ts-expect-error106 schema.omit({ $unknown: true });107 // @ts-expect-error108 schema.required({ $unknown: true });109 // @ts-expect-error110 schema.partial({ $unknown: true });111});112 