1+ script "CoreChunksSegment"
2+ /*
3+ Copyright (C) 2015 Runtime Revolution Ltd.
4+
5+ This file is part of LiveCode.
6+
7+ LiveCode is free software; you can redistribute it and/or modify it under
8+ the terms of the GNU General Public License v3 as published by the Free
9+ Software Foundation.
10+
11+ LiveCode is distributed in the hope that it will be useful, but WITHOUT ANY
12+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ for more details.
15+
16+ You should have received a copy of the GNU General Public License
17+ along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
18+
19+ on TestSegmentRanges
20+ TestAssert "overlong prefix" , segment - 4 to - 2 of "three segment sentence" is "three segment"
21+ TestAssert "overlong suffix" , segment 2 to 4 of "three segment sentence" is "segment sentence"
22+ end TestSegmentRanges
23+
24+ on TestSegmentRangesEmpty
25+ TestAssert "empty prefix" , segment - 5 to - 4 of "three segment sentence" is ""
26+ TestAssert "empty suffix" , segment 4 to 5 of "three segment sentence" is ""
27+ TestAssert "empty range" , segment 5 to 4 of "three segment sentence" is ""
28+ end TestSegmentRangesEmpty
29+
30+ on TestSegmentRangesSingle
31+ TestAssert "single segment range" , segment 1 to 1 of "three segment sentence" is "three"
32+ TestAssert "single segment range from back" , segment - 2 to - 2 of "three segment sentence" is "segment"
33+ end TestSegmentRangesSingle
34+
35+ on TestSegmentExpressions
36+ TestAssert "single segment" , segment 1 of "three segment sentence" is "three"
37+ TestAssert "single segment from back" , segment - 3 of "three segment sentence" is "three"
38+ end TestSegmentExpressions
39+
40+ on TestSegmentExpressionsQuoted
41+ local tVar
42+ put quote & "first segment" & quote && "and" && quote & "third segment" & quote into tVar
43+ TestAssert "single segment quoted" , segment 2 of tVar is "and"
44+ TestAssert "single segment quoted from back" , segment - 2 of tVar is "and"
45+ end TestSegmentExpressionsQuoted
46+
47+ on TestSegmentExpressionsEmpty
48+ TestAssert "single segment" , segment 4 of "three segment sentence" is ""
49+ TestAssert "single segment" , segment - 4 of "three segment sentence" is ""
50+ end TestSegmentExpressionsEmpty
51+
52+ on TestSegmentLineBreakCount
53+ TestAssert "count with line break" , the number of segments in ("one" & return & "two" ) is 2
54+ TestAssert "count with line break quoted" , the number of segments in (quote & "one" & return & "two" & quote ) is 2
55+ end TestSegmentLineBreakCount
56+
57+ on TestSegmentLineBreakExpression
58+ TestAssert "single segment" , segment 2 of ("one" & return & "two" ) is "two"
59+ TestAssert "single segment quoted" , segment 2 of (quote & "one" & return & "two" & quote ) is ("two" & quote )
60+ end TestSegmentLineBreakExpression
61+
62+ on TestSegmentCount
63+ TestAssert "count" , the number of segments in "three segment sentence" is 3
64+ TestAssert "count" , the number of segments in (quote & "one segment sentence" & quote ) is 1
65+ end TestSegmentCount
66+
67+ on TestBug16161
68+ local tLine , tExpected
69+ put "assert true (comma is" && quote & "," & quote && "AND comma is numToChar(44))" into tLine
70+ put "(comma is" && quote & "," & quote && "AND comma is numToChar(44))" into tExpected
71+ TestAssert "comma is not word delimiter" , word 3 to - 1 of tLine is tExpected
72+ end TestBug16161
0 commit comments