Skip to main content
Glama
by microsoft
math.test.ts1.28 kB
import { describe, test } from "node:test" import assert from "node:assert/strict" import { MathTryEvaluate } from "./math" describe("MathTryEvaluate", async () => { await test("evaluates a simple expression", async () => { const result = await MathTryEvaluate("1 + 1") assert.equal(result, 2) }) await test("evaluates an expression with variables from scope", async () => { const result = await MathTryEvaluate("x + y", { scope: { x: 5, y: 3 }, }) assert.equal(result, 8) }) await test("returns defaultValue for empty expression", async () => { const result = await MathTryEvaluate("", { defaultValue: 42, }) assert.equal(result, 42) }) await test("returns undefined for invalid expression", async () => { const result = await MathTryEvaluate("1 +") assert.equal(result, undefined) }) await test("returns undefined for expression with undefined variables", async () => { const result = await MathTryEvaluate("x + y") assert.equal(result, undefined) }) await test("handles complex expressions", async () => { const result = await MathTryEvaluate("sin(PI/2)") assert.equal(result, 1) }) })

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/microsoft/genaiscript'

If you have feedback or need assistance with the MCP directory API, please join our Discord server