File: casts.bsh

package info (click to toggle)
bsh 1.0-beta-2
  • links: PTS
  • area: contrib
  • in suites: potato
  • size: 1,804 kB
  • ctags: 1,857
  • sloc: java: 14,653; makefile: 53; sh: 14
file content (31 lines) | stat: -rw-r--r-- 459 bytes parent folder | download | duplicates (2)
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
#!/bin/java bsh.Interpreter

source("TestHarness.bsh");

f=(float)5;

assert( ((int)0.5) == 0 );

a=0.3;
assert( ((int)a) == 0 );

d=(double)+1;

// cast error should be changed to throw classcastexception which could 
// be caught
assert( isEvalError(
  "i=(Integer)\"foo\";"
) );

try {
  i=(Integer)"foo";
} catch ( ArithmeticException e0 ) {
	assert(false); // just checking
} catch ( ClassCastException e ) {
	flag();
}

assert(flag()==1);

complete();