-
-
Notifications
You must be signed in to change notification settings - Fork 467
/
statements.zep
102 lines (82 loc) · 2.55 KB
/
statements.zep
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
100
101
102
namespace Stub;
class Statements
{
public tmp1 = "test";
public tmp2 = "test string";
/**
* @issue https://github.com/zephir-lang/zephir/issues/544
*/
private totalSteps = 100;
private width = 100;
private filledChar = "=";
private unfilledChar = ".";
private arrow = ">";
public function testPropertyAcccessAvoidTmpReuse()
{
var result1, result2, result3, result4;
let result1 = strpos(this->tmp2, this->tmp1);
let result2 = strpos(this->tmp2, this->tmp1);
let result3 = strpos(this->tmp2, this->tmp1);
let result4 = strpos(this->tmp2, this->tmp1);
}
public function testElseIf(int num)
{
if num > 0 {
return "more";
} elseif num == 0 {
return "equal";
} elseif num == -1 {
return "-1";
} else {
return "less";
}
}
public function testElseIf1(int num)
{
var total = 10;
if (num < total) {
return "less";
} elseif (num == total) {
return "equal";
} else {
return "else";
}
}
public function testElseIf2(int num, total)
{
if (num < total) {
return "less";
} elseif (num == total) {
return "equal";
} else {
return "else";
}
}
public function test544Issue(int! step)
{
int filledWidth, unfilledWidth;
if step < this->totalSteps {
let filledWidth = (this->width - 1) / this->totalSteps * step;
let unfilledWidth = (this->width - 1) - filledWidth;
return str_repeat(this->filledChar, filledWidth).this->arrow.str_repeat(this->unfilledChar, unfilledWidth);
} elseif step === this->totalSteps {
return str_repeat(this->filledChar, this->width);
} else {
return str_repeat(this->unfilledChar, this->width);
}
}
public function test544IssueWithVariable(int! step)
{
int filledWidth, unfilledWidth, totalSteps;
let totalSteps = this->totalSteps;
if step < totalSteps {
let filledWidth = (this->width - 1) / totalSteps * step;
let unfilledWidth = (this->width - 1) - filledWidth;
return str_repeat(this->filledChar, filledWidth).this->arrow.str_repeat(this->unfilledChar, unfilledWidth);
} elseif step === totalSteps {
return str_repeat(this->filledChar, this->width);
} else {
return str_repeat(this->unfilledChar, this->width);
}
}
}