From 85fc7fabf9fbcbed52c46197178eba784b4b8599 Mon Sep 17 00:00:00 2001 From: Mahrud Sayrafi Date: Mon, 26 Aug 2024 03:54:15 +0200 Subject: [PATCH] added tests for locate --- M2/Macaulay2/tests/normal/locate.m2 | 37 +++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 M2/Macaulay2/tests/normal/locate.m2 diff --git a/M2/Macaulay2/tests/normal/locate.m2 b/M2/Macaulay2/tests/normal/locate.m2 new file mode 100644 index 0000000000..b91855d13b --- /dev/null +++ b/M2/Macaulay2/tests/normal/locate.m2 @@ -0,0 +1,37 @@ +f = () -> if ( true ) then ( "true" ) else ( "false" ) +assert( ((F = functionBody f;)) === null ); +assert( ((c = pseudocode f;)) === null ); +assert( ((C = pseudocode F;)) === null ); +getcols = P -> (toList P)_{2,4,6} +assert( (getcols locate f) === {4,54,7} ); +assert( (getcols locate f) === {4,54,7} ); +assert( (getcols locate F) === {4,54,7} ); +assert( (getcols locate c) === {10,54,43} ); +assert( (getcols locate C) === {10,54,43} ); +assert( (getcols locate C_0) === {15,19,15} ); +assert( (getcols locate C_1) === {29,35,29} ); +assert( (getcols locate C_2) === {45,52,45} ); +end-- +-* +-- to update this file simply run these lines: +src = last separate("end-{2,}", get "locate.m2"); +"locate.m2" << generateAssertions src << endl; +"locate.m2" << "end" << "--" << src << close; +*- +-- 0 0 1 1 1 1 2 2 2 2 3 3 3 4 4 5 5 +-- 4 7 0 3 5 8 0 2 7 9 4 6 8 3 5 1 3 +f = () -> if ( true ) then ( "true" ) else ( "false" ) +(F = functionBody f;) +(c = pseudocode f;) +(C = pseudocode F;) +getcols = P -> (toList P)_{2,4,6} +getcols locate f +getcols locate f-* why is focus on '->'? *- +getcols locate F +getcols locate c-* why is focus on '( "false" )'? *- +getcols locate C +getcols locate C_0 +getcols locate C_1 +getcols locate C_2 + +-- TODO: add tests for other kinds of code as well