01: /*
02: * $Id: SyntaxErrorMessageTest.java 2392 2005-07-01 03:01:19Z fraz $
03: *
04: * Copyright (c) 2005 The Codehaus - http://groovy.codehaus.org
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
12: * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: *
14: * See the License for the specific language governing permissions and limitations under the License.
15: *
16: */
17:
18: package org.codehaus.groovy.control.messages;
19:
20: import junit.framework.TestCase;
21:
22: import org.codehaus.groovy.control.SourceUnit;
23: import org.codehaus.groovy.syntax.SyntaxException;
24:
25: public class SyntaxErrorMessageTest extends TestCase {
26:
27: public void testSetsTheSourceLocatorOfItsSyntaxExceptionAsTheNameOfTheCorrespondingSourceUnitWhenInstantiated() {
28: SyntaxException syntaxException = new SyntaxException(
29: someString(), -1, -1);
30: assertEquals("source locator", null, syntaxException
31: .getSourceLocator());
32:
33: String sourceUnitName = someString();
34: SourceUnit sourceUnit = SourceUnit.create(sourceUnitName,
35: someString());
36:
37: new SyntaxErrorMessage(syntaxException, sourceUnit);
38: assertEquals("source locator", sourceUnitName, syntaxException
39: .getSourceLocator());
40: }
41:
42: private String someString() {
43: return String.valueOf(Math.random()
44: * System.currentTimeMillis());
45: }
46: }
|