MCPcopy
hub / github.com/google/mangle / TestString

Function TestString

ast/ast_test.go:272–345  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

270}
271
272func TestString(t *testing.T) {
273 tests := []struct {
274 name string
275 term Term
276 want string
277 }{
278 {
279 "name constant",
280 name("/foo"),
281 "/foo",
282 },
283 {
284 "number constant",
285 Number(52),
286 "52",
287 },
288 {
289 "float constant",
290 Float64(52.34),
291 "52.34",
292 },
293 {
294 "pair constant",
295 fooBarPair,
296 `fn:pair(/foo, "bar")`,
297 },
298 {
299 "list constant",
300 fooBarList,
301 `[/foo, "bar"]`,
302 },
303 {
304 "variable",
305 Variable{"X"},
306 "X",
307 },
308 {
309 "atom",
310 NewAtom("bar", Variable{"X"}),
311 "bar(X)",
312 },
313 {
314 "moreargs",
315 NewAtom("bar", Variable{"X"}, Variable{"Y"}, name("/foo")),
316 "bar(X,Y,/foo)",
317 },
318 {
319 "negated atom",
320 NewNegAtom("bar", Variable{"X"}),
321 "!bar(X)",
322 },
323 {
324 "equality",
325 Eq{name("/bar"), Variable{"X"}},
326 "/bar = X",
327 },
328 {
329 "equality 2",

Callers

nothing calls this directly

Calls 6

NumberFunction · 0.85
Float64Function · 0.85
NewAtomFunction · 0.85
NewNegAtomFunction · 0.85
nameFunction · 0.70
StringMethod · 0.65

Tested by

no test coverage detected