@@ -2,9 +2,10 @@ object pepita {
2
2
var energy = 0
3
3
4
4
// self is the void method
5
- method eat (something) {
5
+ method ingest (something) {
6
6
energy -= something
7
7
}
8
+
8
9
}
9
10
10
11
class A {
@@ -17,34 +18,29 @@ class MethodsCalledOnWellKnowObjects inherits A {
17
18
18
19
19
20
method asParameter() {
20
- // XPECT errors --> "Message send "eat(10)" produces no value (missing return in method?)" at "eat"
21
- self .setA(pepita.eat(10 ))
21
+ self .setA(@Expect(code = " shouldNotUseVoidMethodAsValue" , message = " error" ) (pepita.ingest(10 )))
22
22
}
23
23
24
24
method initialization(aParam) {
25
- // XPECT errors --> "Message send "eat(10)" produces no value (missing return in method?)" at "eat"
26
- const a = pepita.eat(10 )
25
+ const a = @Expect(code = " shouldNotUseVoidMethodAsValue" , message = " error" ) (pepita.ingest(10 ))
27
26
28
27
self .setA(a)
29
28
}
30
29
31
30
method assignment(aParam) {
32
31
var a = null
33
32
34
- // XPECT errors --> "Message send "eat(10)" produces no value (missing return in method?)" at "eat"
35
- a = pepita.eat(10 )
33
+ a = @Expect(code = " shouldNotUseVoidMethodAsValue" , message = " error" ) (pepita.ingest(10 ))
36
34
37
35
self .setA(a)
38
36
}
39
37
40
38
method asReturnValue() {
41
- // XPECT errors --> "Message send "eat(10)" produces no value (missing return in method?)" at "eat"
42
- return pepita.eat(10 )
39
+ return @Expect(code = " shouldNotUseVoidMethodAsValue" , message = " error" ) (pepita.ingest(10 ))
43
40
}
44
41
45
42
method asAnIfCondition() {
46
- // XPECT errors --> "Message send "eat(10)" produces no value (missing return in method?)" at "eat"
47
- return if (pepita.eat(10 ))
43
+ return if (@Expect(code = " shouldNotUseVoidMethodAsValue" , message = " error" ) (pepita.ingest(10 )))
48
44
20
49
45
else
50
46
30
@@ -53,39 +49,30 @@ class MethodsCalledOnWellKnowObjects inherits A {
53
49
method asABinaryOperatorArgument() {
54
50
const cond = true
55
51
return [
56
- // XPECT errors --> "Message send "eat(10)" produces no value (missing return in method?)" at "eat"
57
- 10 + pepita.eat(10 ),
58
- // XPECT errors --> "Message send "eat(10)" produces no value (missing return in method?)" at "eat"
59
- 10 * pepita.eat(10 ),
60
- // XPECT errors --> "Message send "eat(10)" produces no value (missing return in method?)" at "eat"
61
- cond && pepita.eat(10 ),
62
- // XPECT errors --> "Message send "eat(10)" produces no value (missing return in method?)" at "eat"
63
- cond || pepita.eat(10 )
52
+ 10 + @Expect(code = " shouldNotUseVoidMethodAsValue" , message = " error" ) (pepita.ingest(10 )),
53
+ 10 * @Expect(code = " shouldNotUseVoidMethodAsValue" , message = " error" ) (pepita.ingest(10 )),
54
+ cond && @Expect(code = " shouldNotUseVoidMethodAsValue" , message = " error" ) (pepita.ingest(10 )),
55
+ cond || @Expect(code = " shouldNotUseVoidMethodAsValue" , message = " error" ) (pepita.ingest(10 ))
64
56
]
65
57
}
66
58
67
59
method asTargetForNewMessageSend() {
68
- // XPECT errors --> "Message send "eat(10)" produces no value (missing return in method?)" at "eat"
69
- pepita.eat(10 ).cantina()
60
+ (@Expect(code = " shouldNotUseVoidMethodAsValue" , message = " error" ) (pepita.ingest(10 ))).cantina()
70
61
}
71
62
72
63
method asListLiteralElement() {
73
- // XPECT errors --> "Message send "eat(10)" produces no value (missing return in method?)" at "eat"
74
- return [1 , 2 , 3 , pepita.eat(10 )]
64
+ return [1 , 2 , @Expect(code = " shouldNotUseVoidMethodAsValue" , message = " error" ) (pepita.ingest(10 ))]
75
65
}
76
66
77
67
override method toBeOverriden(a) {
78
- // XPECT errors --> "Message send "eat(10)" produces no value (missing return in method?)" at "eat"
79
- super (pepita.eat(10 ))
68
+ super (@Expect(code = " shouldNotUseVoidMethodAsValue" , message = " error" ) (pepita.ingest(10 )))
80
69
}
81
70
82
71
method asConstructorArg() {
83
- // XPECT errors --> "Message send "eat(10)" produces no value (missing return in method?)" at "eat"
84
- return new B(a = pepita.eat(10 ))
72
+ return new B(a = @Expect(code = " shouldNotUseVoidMethodAsValue" , message = " error" ) (pepita.ingest(10 )))
85
73
}
86
74
87
- // XPECT errors --> "Message send "eat(10)" produces no value (missing return in method?)" at "eat"
88
- method asExpressionOnMethodShortcut() = pepita.eat(10 )
75
+ method asExpressionOnMethodShortcut() = @Expect(code = " shouldNotUseVoidMethodAsValue" , message = " error" ) (pepita.ingest(10 ))
89
76
}
90
77
91
78
class B {
0 commit comments