1+ script "CoreEngineBehavior"
2+ /*
3+ Copyright (C) 2016 LiveCode 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 _TestCyclicBehavior pStack
20+ set the behavior of (the behavior of pStack ) to pStack
21+ end _TestCyclicBehavior
22+
23+ on TestCyclicBehavior
24+ create stack "Behavior"
25+ create stack
26+ set the behavior of it to the long id of stack "Behavior"
27+ TestAssertThrow "cycle in behavior script hierarchy throws" , \
28+ "_TestCyclicBehavior" , the long id of me, 678 , it
29+ end TestCyclicBehavior
30+
31+ on TestInvalidBehaviorChange
32+ local tScript
33+ put "on changeBehavior" & return into tScript
34+ put "set the behavior of me to the long id of stack" && quote & "NewBehavior" & quote & return after tScript
35+ put "end changeBehavior" after tScript
36+
37+ create stack "NewBehavior"
38+ create stack "Behavior"
39+ set the script of it to tScript
40+
41+ create stack
42+ set the behavior of it to the long id of stack "Behavior"
43+ TestAssertThrow "behavior change while parent script is executing throws" , \
44+ "changeBehavior" , it , 895
45+ end TestInvalidBehaviorChange
0 commit comments