-
Notifications
You must be signed in to change notification settings - Fork 8
/
lib.html
149 lines (139 loc) · 10.3 KB
/
lib.html
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<h2 id="console"><img src="images/object.png" height="24px" width="24px" title="object"/>
console</h2>
<p> Console is a global wollok object that implements a character-based console device<br>called "standard input/output" stream</p>
<h3> Behavior</h3>
<div class="container"><table class="table table-striped table-hover table-sm w-auto">
<thead>
<tr>
<th class="blue-grey lighten-2">Method</th>
<th class="blue-grey lighten-2">Description</th>
</tr>
</thread>
<tbody>
<tr>
<td title="console" width="30%" id="console_newline_0"><code><b>newline</b>()</code> <span class="badge badge-pill indigo">native</span><br>
</td><td width="70%;">Returns the system's representation of a new line:<br>- \n in Unix systems<br>- \r\n in Windows systems</td>
</tr>
<tr>
<td title="console" width="30%" id="console_println_1"><code><b>println</b>(obj)</code> <span class="badge badge-pill indigo">native</span><br>
</td><td width="70%;">Prints a String with end-of-line character</td>
</tr>
<tr>
<td title="console" width="30%" id="console_readInt_0"><code><b>readInt</b>()</code> <span class="badge badge-pill indigo">native</span><br>
</td><td width="70%;">Reads an int character from input stream</td>
</tr>
<tr>
<td title="console" width="30%" id="console_readLine_0"><code><b>readLine</b>()</code> <span class="badge badge-pill indigo">native</span><br>
</td><td width="70%;">Reads a line from input stream</td>
</tr>
</tbody>
</table></div>
<hr>
<h2 id="OtherValueExpectedException"><img src="images/class.png" height="24px" width="24px" title="class"/>
OtherValueExpectedException</h2>
<ul>
<li>inherits from <a href="javascript:selectFile('lang', 'Exception')">Exception</a>
</li>
</ul>
<p> Exception to handle other values expected in assert.throwsException... methods</p>
<hr>
<h2 id="AssertionException"><img src="images/class.png" height="24px" width="24px" title="class"/>
AssertionException</h2>
<ul>
<li>inherits from <a href="javascript:selectFile('lang', 'Exception')">Exception</a>
</li>
</ul>
<p> Exception to handle difference between current and expected values<br>in assert.throwsException... methods</p>
<h3> Attributes</h3>
<div class="container"><table class="table table-striped table-hover table-sm w-auto">
<tr>
<td title="expected" width="30%"><code><b>expected</b></code> </td><td width="70%;"></td>
</tr>
<tr>
<td title="actual" width="30%"><code><b>actual</b></code> </td><td width="70%;"></td>
</tr>
</table></div>
<hr>
<hr>
<h2 id="assert"><img src="images/object.png" height="24px" width="24px" title="object"/>
assert</h2>
<p> Assert object simplifies testing conditions</p>
<h3> Behavior</h3>
<div class="container"><table class="table table-striped table-hover table-sm w-auto">
<thead>
<tr>
<th class="blue-grey lighten-2">Method</th>
<th class="blue-grey lighten-2">Description</th>
</tr>
</thread>
<tbody>
<tr>
<td title="assert" width="30%" id="assert_doesNotThrowException_1"><code><b>doesNotThrowException</b>(block)</code> </td><td width="70%;">Tests that a block does not throw any kind of exception. Block expects no parameters.</td>
</tr>
<tr>
<td title="assert" width="30%" id="assert_equals_2"><code><b>equals</b>(expected, actual)</code> </td><td width="70%;">Tests whether two values are equal, based on wollok ==, != methods<br><br>Examples:<br> assert.equals(10, 100.div(10)) ==> ok, nothing happens<br> assert.equals(10.0, 100.div(10)) ==> ok, nothing happens<br> assert.equals(10.01, 100.div(10)) ==> throws an exception</td>
</tr>
<tr>
<td title="assert" width="30%" id="assert_equals_1"><code><b>equals</b>(value)</code> </td><td width="70%;">This method avoids confusion with equals definition in Object</td>
</tr>
<tr>
<td title="assert" width="30%" id="assert_fail_1"><code><b>fail</b>(message)</code> </td><td width="70%;">Throws an exception with a custom message.<br>Useful when you reach code that should not be reached.</td>
</tr>
<tr>
<td title="assert" width="30%" id="assert_notEquals_2"><code><b>notEquals</b>(expected, actual)</code> </td><td width="70%;">Tests whether two values are equal, based on wollok ==, != methods<br><br>Examples:<br> const value = 5<br> assert.notEquals(10, value * 3) ==> ok, nothing happens<br> assert.notEquals(10, value) ==> throws an exception</td>
</tr>
<tr>
<td title="assert" width="30%" id="assert_notThat_1"><code><b>notThat</b>(value)</code> </td><td width="70%;">Tests whether value is false. Otherwise throws an exception.<br><b>see</b> assert#that(value)</td>
</tr>
<tr>
<td title="assert" width="30%" id="assert_that_1"><code><b>that</b>(value)</code> </td><td width="70%;">Tests whether value is true. Otherwise throws an exception.<br><br>Example:<br> assert.that(7.even()) ==> throws an exception "Value was not true"<br> assert.that(8.even()) ==> ok, nothing happens</td>
</tr>
<tr>
<td title="assert" width="30%" id="assert_throwsException_1"><code><b>throwsException</b>(block)</code> </td><td width="70%;">Tests whether a block throws an exception. Otherwise an exception is thrown.<br><br>Examples:<br> assert.throwsException({ 7 / 0 })<br> ==> Division by zero error, it is expected, ok<br><br> assert.throwsException({ "hola".length() })<br> ==> throws an exception "Block should have failed"</td>
</tr>
<tr>
<td title="assert" width="30%" id="assert_throwsExceptionByComparing_2"><code><b>throwsExceptionByComparing</b>(block, comparison)</code> </td><td width="70%;">Tests whether a block throws an exception and compare this exception with other block<br>called comparison. Otherwise an exception is thrown. The block comparison<br>receives a value (an exception thrown) that is compared in a boolean expression<br>returning the result.<br><br>Examples:<br> assert.throwsExceptionByComparing({ => throw new BusinessException(message = "hola"), { ex => "hola" == ex.message()}}<br> => Works!.<br><br> assert.throwsExceptionByComparing({ => throw new BusinessException(message = "hola"), { ex => new BusinessException(message = "lele").className() == ex.className()} }<br> => Works again!<br><br> assert.throwsExceptionByComparing({ => throw new BusinessException(message = "hola"), { ex => "chau!" == ex.message()} }<br> => Doesn't work. The block evaluation resolves to a false value.</td>
</tr>
<tr>
<td title="assert" width="30%" id="assert_throwsExceptionLike_2"><code><b>throwsExceptionLike</b>(exceptionExpected, block)</code> </td><td width="70%;">Tests whether a block throws an exception and this is the same expected.<br>Otherwise an exception is thrown.<br><br>Examples:<br> assert.throwsExceptionLike(new BusinessException(message = "hola"),<br> { => throw new BusinessException(message = "hola") }<br> => Works! Exception class and message both match.<br><br> assert.throwsExceptionLike(new BusinessException(message = "chau"),<br> { => throw new BusinessException(message = "hola") }<br> => Doesn't work. Exception class matches but messages are different.<br><br> assert.throwsExceptionLike(new OtherException(message = "hola"),<br> { => throw new BusinessException(message = "hola") }<br> => Doesn't work. Messages matches but they are instances of different exceptions.</td>
</tr>
<tr>
<td title="assert" width="30%" id="assert_throwsExceptionWithMessage_2"><code><b>throwsExceptionWithMessage</b>(errorMessage, block)</code> </td><td width="70%;">Tests whether a block throws an exception and it has the error message as is expected.<br>Otherwise an exception is thrown.<br><br>Examples:<br> assert.throwsExceptionWithMessage("hola",{ => throw new BusinessException(message = "hola") }<br> => Works! Both have the same message.<br><br> assert.throwsExceptionWithMessage("hola",{ => throw new OtherException(message = "hola") }<br> => Works! Both have the same message.<br><br> assert.throwsExceptionWithMessage("chau",{ => throw new BusinessException(message = "hola") }<br> => Doesn't work. Both are instances of BusinessException but their messages differ.</td>
</tr>
<tr>
<td title="assert" width="30%" id="assert_throwsExceptionWithType_2"><code><b>throwsExceptionWithType</b>(exceptionExpected, block)</code> </td><td width="70%;">Tests whether a block throws an exception and this is the same exception class expected.<br>Otherwise an exception is thrown.<br><br>Examples:<br> assert.throwsExceptionWithType(new BusinessException(message = "hola"),{ => throw new BusinessException(message = "hola") }<br> => Works! Both exceptions are instances of the same class.<br><br> assert.throwsExceptionWithType(new BusinessException(message = "chau"),{ => throw new BusinessException(message = "hola") }<br> => Works again! Both exceptions are instances of the same class.<br><br> assert.throwsExceptionWithType(new OtherException(message = "hola"),{ => throw new BusinessException(message = "hola") }<br> => Doesn't work. Exception classes differ although they contain the same message.</td>
</tr>
</tbody>
</table></div>
<hr>
<h2 id="StringPrinter"><img src="images/class.png" height="24px" width="24px" title="class"/>
StringPrinter</h2>
<p> </p>
<h3> Attributes</h3>
<div class="container"><table class="table table-striped table-hover table-sm w-auto">
<tr>
<td title="buffer" width="30%"><code><b>buffer</b></code> </td><td width="70%;"></td>
</tr>
</table></div>
<hr>
<h3> Behavior</h3>
<div class="container"><table class="table table-striped table-hover table-sm w-auto">
<thead>
<tr>
<th class="blue-grey lighten-2">Method</th>
<th class="blue-grey lighten-2">Description</th>
</tr>
</thread>
<tbody>
<tr>
<td title="StringPrinter" width="30%" id="StringPrinter_getBuffer_0"><code><b>getBuffer</b>()</code> </td><td width="70%;"></td>
</tr>
<tr>
<td title="StringPrinter" width="30%" id="StringPrinter_println_1"><code><b>println</b>(obj)</code> </td><td width="70%;"></td>
</tr>
</tbody>
</table></div>
<hr>
<div class="container">
</div>
<p>Last update: 09/07/2021 16:16:49</p>