File: eval.html

package info (click to toggle)
jswat2 2.37-1
  • links: PTS
  • area: contrib
  • in suites: etch, etch-m68k
  • size: 7,092 kB
  • ctags: 5,592
  • sloc: java: 43,576; xml: 1,086; sh: 66; makefile: 57
file content (196 lines) | stat: -rw-r--r-- 4,087 bytes parent folder | download
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta name="generator"
    content="HTML Tidy for Linux/x86 (vers 1st February 2002), see www.w3.org" />

    <title>JSwat - Testing Expressions</title>
  </head>

  <body bgcolor="#ffffff">
    <h2>Testing Expressions</h2>

    <h3>Introduction</h3>

    <p>JSwat supports the evaluation of Java-like expressions. See the
    built-in &quot;Expression Evaluation&quot; help screen to learn
    more about them. In short, most of the expressions defined in the
    JLS are supported.</p>

    <h3>Test Cases</h3>

    <table border="1" summary="expressions">
      <tr>
        <th>Expression</th>

        <th>Result</th>

        <th>Notes</th>
      </tr>

      <tr>
        <td><code>123</code></td>

        <td><code>123</code></td>

        <td>numeric literals are returned as-is</td>
      </tr>

      <tr>
        <td><code>true</code></td>

        <td><code>true</code></td>

        <td>boolean literals are returned as-is</td>
      </tr>

      <tr>
        <td><code>null</code></td>

        <td><code>null</code></td>

        <td>null is returned as-is</td>
      </tr>

      <tr>
        <td><code>&quot;abc&quot;</code></td>

        <td><code>abc</code></td>

        <td>string literals have their quotes removed</td>
      </tr>

      <tr>
        <td><code>var</code></td>

        <td>var&#39;s value</td>

        <td>variable references are replaced with the variable
        value</td>
      </tr>

      <tr>
        <td><code>1 + 1</code></td>

        <td><code>2</code></td>

        <td>simple arithmetic expressions are evaluated</td>
      </tr>

      <tr>
        <td><code>1 == 1</code></td>

        <td><code>true</code></td>

        <td>equality expression</td>
      </tr>

      <tr>
        <td><code>i == 1</code></td>

        <td><code>true</code> if i is one</td>

        <td>variable and literal equality expression</td>
      </tr>

      <tr>
        <td><code>1 != 1</code></td>

        <td><code>false</code></td>

        <td>equality expression</td>
      </tr>

      <tr>
        <td><code>i != 1</code></td>

        <td><code>true</code> if i is not one</td>

        <td>variable and literal equality expression</td>
      </tr>

      <tr>
        <td><code>2 &gt; 1</code></td>

        <td><code>true</code></td>

        <td>relational expression</td>
      </tr>

      <tr>
        <td><code>i &gt; 1</code></td>

        <td><code>true</code> if i is greater than one</td>

        <td>variable to literal relational expression</td>
      </tr>

      <tr>
        <td><code>2.2 &gt;= 2.2</code></td>

        <td><code>true</code></td>

        <td>relational expression (with floating point operands)</td>
      </tr>

      <tr>
        <td><code>1 + 2 * 3</code></td>

        <td><code>7</code></td>

        <td>operator precedence follows JLS</td>
      </tr>

      <tr>
        <td><code>(1 + 2) * 3</code></td>

        <td><code>9</code></td>

        <td>parentheses override operator precedence</td>
      </tr>

      <tr>
        <td><code>arr[1 + 1]</code></td>

        <td>value of third element of arr (an array)</td>

        <td>expressions as array indices</td>
      </tr>

      <tr>
        <td><code>arr[meth(2 + 2)]</code></td>

        <td>value of nth element of arr (an array)</td>

        <td>method invocation as array index</td>
      </tr>

      <tr>
        <td><code>meth(true, 2 * 3, null)</code></td>

        <td>method return value</td>

        <td>expressions as method arguments</td>
      </tr>

      <tr>
        <td><code>meth(2 * (3 + 1), a == b, 255 &amp; 32)</code></td>

        <td>method return value</td>

        <td>more complex method invocation</td>
      </tr>

      <tr>
        <td><code>meth(a == b, meth2(123), 255 &amp; 32)</code></td>

        <td>method return value</td>

        <td>nested method invocation</td>
      </tr>
    </table>
  </body>
</html>