variables.at
3.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# This file is part of GNU Mailutils. -*- Autotest -*-
# Copyright (C) 2016-2017 Free Software Foundation, Inc.
#
# GNU Mailutils is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3, or (at
# your option) any later version.
#
# GNU Mailutils is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
AT_BANNER([Variables extension])
MUT_TESTCASE([match variable],[variables match match-variable],
[require [["variables", "fileinto"]];
if address :matches [[ "To", "Cc" ] [ "*@**.com", "*@**.edu" ]]
{
fileinto "INBOX.${3}.${1}";
}],
[],[0],[],
[FILEINTO on msg uid 1: delivering into INBOX.acme.example.roadrunner
FILEINTO on msg uid 2: delivering into INBOX.landru.example.rube
IMPLICIT KEEP on msg uid 3
])
MUT_TESTCASE([set action],[variables action set],
[require [["variables", "fileinto"]];
set "name" "value";
fileinto "INBOX.${name}";
],
[],[0],[],
[FILEINTO on msg uid 1: delivering into INBOX.value
FILEINTO on msg uid 2: delivering into INBOX.value
FILEINTO on msg uid 3: delivering into INBOX.value
])
MUT_TESTCASE([variables with encoded characters],[variables encoded-character],
[require [["encoded-character", "variables", "fileinto"]];
set "myvar" "INBOX";
fileinto "${${hex: 6D 79 76}ar}";
],
[],[0],[],
[FILEINTO on msg uid 1: delivering into INBOX
FILEINTO on msg uid 2: delivering into INBOX
FILEINTO on msg uid 3: delivering into INBOX
])
MUT_TESTCASE([set modifiers],[variables action set],
[require [["variables", "fileinto"]];
set "name" :upperfirst :lower "VALUE";
fileinto "INBOX.${name}";
],
[],[0],[],
[FILEINTO on msg uid 1: delivering into INBOX.Value
FILEINTO on msg uid 2: delivering into INBOX.Value
FILEINTO on msg uid 3: delivering into INBOX.Value
])
MUT_TESTCASE([:quotewildcard modifier],[variables action set],
[require [["variables", "fileinto"]];
set "name" :quotewildcard ".a*strange?name\\!";
fileinto "INBOX${name}";
],
[],[0],[],
[FILEINTO on msg uid 1: delivering into INBOX.a\*strange\?name\\!
FILEINTO on msg uid 2: delivering into INBOX.a\*strange\?name\\!
FILEINTO on msg uid 3: delivering into INBOX.a\*strange\?name\\!
])
MUT_TESTCASE([:length modifier],[variables action set],
[require [["variables", "fileinto"]];
set "name" :length "value";
fileinto "INBOX.${name}";
],
[],[0],[],
[FILEINTO on msg uid 1: delivering into INBOX.5
FILEINTO on msg uid 2: delivering into INBOX.5
FILEINTO on msg uid 3: delivering into INBOX.5
])
MUT_TESTCASE([string test],[variables test string],
[require "variables";
if address "To" :matches "*@*.*.*"
{
if string "${2}" [[ "landru", "ACME" ]]
{
discard;
}
}],
[],[0],[],
[DISCARD on msg uid 1: marking as deleted
DISCARD on msg uid 2: marking as deleted
IMPLICIT KEEP on msg uid 3
])