From 0c74290519ee999002e9cc99ba3d272d68e1014f Mon Sep 17 00:00:00 2001 From: Laurenz Date: Thu, 8 Jul 2021 23:36:20 +0200 Subject: Compare functions and templates by identity --- tests/typ/code/ops.typ | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests/typ/code/ops.typ') diff --git a/tests/typ/code/ops.typ b/tests/typ/code/ops.typ index 6d788df1..58fd957f 100644 --- a/tests/typ/code/ops.typ +++ b/tests/typ/code/ops.typ @@ -112,6 +112,7 @@ --- // Test equality operators. +// Most things compare by value. #test(1 == "hi", false) #test(1 == 1.0, true) #test(30% == 30% + 0cm, true) @@ -124,6 +125,17 @@ #test((a: 2 - 1.0, b: 2) == (b: 2, a: 1), true) #test("a" != "a", false) +// Functions compare by identity. +#test(test == test, true) +#test((() => {}) == (() => {}), false) + +// Templates also compare by identity. +#let t = [a] +#test(t == t, true) +#test([] == [], false) +#test([] == [a], false) +#test([a] == [a], false) + --- // Test comparison operators. -- cgit v1.2.3