01: /*
02: * Copyright 2006, 2007 Odysseus Software GmbH
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package de.odysseus.el.tree.impl.ast;
17:
18: import javax.el.ELException;
19:
20: import de.odysseus.el.TestCase;
21:
22: public class AstNumberTest extends TestCase {
23: AstNumber parseNode(String expression) {
24: return (AstNumber) parse(expression).getRoot().getChild(0);
25: }
26:
27: public void testEval() {
28: assertEquals(1l, parseNode("${1}").eval(null, null));
29: assertEquals(1d, parseNode("${1.0}").eval(null, null));
30: }
31:
32: public void testAppendStructure() {
33: StringBuilder s = new StringBuilder();
34: parseNode("${1}").appendStructure(s, null);
35: assertEquals("1", s.toString());
36: }
37:
38: public void testIsLiteralText() {
39: assertFalse(parseNode("${1}").isLiteralText());
40: }
41:
42: public void testIsLeftValue() {
43: assertFalse(parseNode("${1}").isLeftValue());
44: }
45:
46: public void testGetType() {
47: assertNull(parseNode("${1}").getType(null, null));
48: }
49:
50: public void testIsReadOnly() {
51: assertTrue(parseNode("${1}").isReadOnly(null, null));
52: }
53:
54: public void testSetValue() {
55: try {
56: parseNode("${1}").setValue(null, null, null);
57: fail();
58: } catch (ELException e) {
59: }
60: }
61:
62: public void testGetValue() {
63: assertEquals(1l, parseNode("${1}").getValue(null, null, null));
64: assertEquals(1d, parseNode("${1}").getValue(null, null,
65: Double.class));
66: }
67: }
|