Modernize o.e.dltk.tcl.core.tests.
* Move to Java 8.
* Enable warnings and save actions.
* Fix warnings.
* Convert to JUnit 4.
Change-Id: I05fb0903cfd24de1e9fa6d48f03fba0acfdccdb3
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
diff --git a/tcl/tests/org.eclipse.dltk.tcl.core.tests/.classpath b/tcl/tests/org.eclipse.dltk.tcl.core.tests/.classpath
index 64c5e31..eca7bdb 100644
--- a/tcl/tests/org.eclipse.dltk.tcl.core.tests/.classpath
+++ b/tcl/tests/org.eclipse.dltk.tcl.core.tests/.classpath
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
diff --git a/tcl/tests/org.eclipse.dltk.tcl.core.tests/.settings/org.eclipse.jdt.core.prefs b/tcl/tests/org.eclipse.dltk.tcl.core.tests/.settings/org.eclipse.jdt.core.prefs
index 397d57f..5356a08 100644
--- a/tcl/tests/org.eclipse.dltk.tcl.core.tests/.settings/org.eclipse.jdt.core.prefs
+++ b/tcl/tests/org.eclipse.dltk.tcl.core.tests/.settings/org.eclipse.jdt.core.prefs
@@ -1,15 +1,14 @@
-#Thu Oct 21 16:32:18 CEST 2010
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.5
+org.eclipse.jdt.core.compiler.source=1.8
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
@@ -88,9 +87,12 @@
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false
org.eclipse.jdt.core.formatter.indentation.size=4
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
-org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
diff --git a/tcl/tests/org.eclipse.dltk.tcl.core.tests/.settings/org.eclipse.jdt.ui.prefs b/tcl/tests/org.eclipse.dltk.tcl.core.tests/.settings/org.eclipse.jdt.ui.prefs
index 9d66d0a..2be769c 100644
--- a/tcl/tests/org.eclipse.dltk.tcl.core.tests/.settings/org.eclipse.jdt.ui.prefs
+++ b/tcl/tests/org.eclipse.dltk.tcl.core.tests/.settings/org.eclipse.jdt.ui.prefs
@@ -1,4 +1,61 @@
-#Thu Oct 21 16:32:18 CEST 2010
eclipse.preferences.version=1
+editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
formatter_profile=org.eclipse.jdt.ui.default.eclipse_profile
formatter_settings_version=11
+sp_cleanup.add_default_serial_version_id=true
+sp_cleanup.add_generated_serial_version_id=false
+sp_cleanup.add_missing_annotations=true
+sp_cleanup.add_missing_deprecated_annotations=true
+sp_cleanup.add_missing_methods=false
+sp_cleanup.add_missing_nls_tags=false
+sp_cleanup.add_missing_override_annotations=true
+sp_cleanup.add_missing_override_annotations_interface_methods=true
+sp_cleanup.add_serial_version_id=false
+sp_cleanup.always_use_blocks=true
+sp_cleanup.always_use_parentheses_in_expressions=false
+sp_cleanup.always_use_this_for_non_static_field_access=false
+sp_cleanup.always_use_this_for_non_static_method_access=false
+sp_cleanup.convert_functional_interfaces=true
+sp_cleanup.convert_to_enhanced_for_loop=false
+sp_cleanup.correct_indentation=false
+sp_cleanup.format_source_code=true
+sp_cleanup.format_source_code_changes_only=false
+sp_cleanup.insert_inferred_type_arguments=false
+sp_cleanup.make_local_variable_final=true
+sp_cleanup.make_parameters_final=false
+sp_cleanup.make_private_fields_final=true
+sp_cleanup.make_type_abstract_if_missing_method=false
+sp_cleanup.make_variable_declarations_final=false
+sp_cleanup.never_use_blocks=false
+sp_cleanup.never_use_parentheses_in_expressions=true
+sp_cleanup.on_save_use_additional_actions=true
+sp_cleanup.organize_imports=true
+sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
+sp_cleanup.remove_private_constructors=true
+sp_cleanup.remove_redundant_type_arguments=true
+sp_cleanup.remove_trailing_whitespaces=true
+sp_cleanup.remove_trailing_whitespaces_all=true
+sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
+sp_cleanup.remove_unnecessary_casts=true
+sp_cleanup.remove_unnecessary_nls_tags=false
+sp_cleanup.remove_unused_imports=true
+sp_cleanup.remove_unused_local_variables=false
+sp_cleanup.remove_unused_private_fields=true
+sp_cleanup.remove_unused_private_members=false
+sp_cleanup.remove_unused_private_methods=true
+sp_cleanup.remove_unused_private_types=true
+sp_cleanup.sort_members=false
+sp_cleanup.sort_members_all=false
+sp_cleanup.use_anonymous_class_creation=false
+sp_cleanup.use_blocks=false
+sp_cleanup.use_blocks_only_for_return_and_throw=false
+sp_cleanup.use_lambda=true
+sp_cleanup.use_parentheses_in_expressions=false
+sp_cleanup.use_this_for_non_static_field_access=false
+sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
+sp_cleanup.use_this_for_non_static_method_access=false
+sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
diff --git a/tcl/tests/org.eclipse.dltk.tcl.core.tests/META-INF/MANIFEST.MF b/tcl/tests/org.eclipse.dltk.tcl.core.tests/META-INF/MANIFEST.MF
index c3d35ce..ab97390 100644
--- a/tcl/tests/org.eclipse.dltk.tcl.core.tests/META-INF/MANIFEST.MF
+++ b/tcl/tests/org.eclipse.dltk.tcl.core.tests/META-INF/MANIFEST.MF
@@ -17,9 +17,9 @@
org.eclipse.dltk.itcl.core,
org.eclipse.dltk.tcl.parser,
org.eclipse.dltk.tcl.parser.tests
-Eclipse-LazyStart: true
+Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.dltk.tcl.core.tests,
org.eclipse.dltk.tcl.core.tests.model,
org.eclipse.dltk.tcl.parser.structure,
org.eclipse.dltk.tcl.parser.tests
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
diff --git a/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/core/tests/AllTests.java b/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/core/tests/AllTests.java
index 15d51f6..bb154c8 100644
--- a/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/core/tests/AllTests.java
+++ b/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/core/tests/AllTests.java
@@ -5,33 +5,22 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
-
+
*******************************************************************************/
package org.eclipse.dltk.tcl.core.tests;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
import org.eclipse.dltk.tcl.core.tests.model.PACompletionTests;
import org.eclipse.dltk.tcl.core.tests.model.PASelectionTests;
import org.eclipse.dltk.tcl.parser.structure.SimpleStructureParserTests;
import org.eclipse.dltk.tcl.parser.structure.StructureParserTests;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+@RunWith(Suite.class)
+@Suite.SuiteClasses({ org.eclipse.dltk.tcl.core.tests.model.AllTests.class,
+ org.eclipse.dltk.tcl.parser.tests.AllTests.class,
+ PACompletionTests.class, PASelectionTests.class,
+ VariableResolverTests.class, TclContentDescriberTests.class,
+ SimpleStructureParserTests.class, StructureParserTests.class })
public class AllTests {
-
- public static Test suite() {
- TestSuite suite = new TestSuite("org.eclipse.dltk.tcl.core.tests"); //$NON-NLS-1$
- // $JUnit-BEGIN$
- suite.addTest(org.eclipse.dltk.tcl.core.tests.model.AllTests.suite());
- suite.addTest(org.eclipse.dltk.tcl.parser.tests.AllTests.suite());
- suite.addTest(PACompletionTests.suite());
- suite.addTest(PASelectionTests.suite());
- suite.addTestSuite(VariableResolverTests.class);
- suite.addTestSuite(TclContentDescriberTests.class);
- suite.addTest(SimpleStructureParserTests.suite());
- suite.addTest(StructureParserTests.suite());
- // $JUnit-END$
- return suite;
- }
-
}
diff --git a/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/core/tests/TclContentDescriberTests.java b/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/core/tests/TclContentDescriberTests.java
index f93d503..7cf3455 100644
--- a/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/core/tests/TclContentDescriberTests.java
+++ b/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/core/tests/TclContentDescriberTests.java
@@ -1,53 +1,60 @@
/*******************************************************************************
- * Copyright (c) 2009 xored software, Inc.
+ * Copyright (c) 2009, 2017 xored software, Inc. and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* xored software, Inc. - initial API and Implementation (Alex Panchenko)
*******************************************************************************/
package org.eclipse.dltk.tcl.core.tests;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.io.IOException;
import java.io.StringReader;
import java.util.HashMap;
import java.util.Map;
-import junit.framework.TestCase;
-
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.core.runtime.content.IContentDescription;
import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.dltk.core.DLTKContentTypeManager;
import org.eclipse.dltk.tcl.core.TclContentDescriber;
import org.eclipse.dltk.utils.TextUtils;
+import org.junit.Test;
@SuppressWarnings("nls")
-public class TclContentDescriberTests extends TestCase {
+public class TclContentDescriberTests {
private static class Description implements IContentDescription {
+ @Override
public String getCharset() {
return null;
}
+ @Override
public IContentType getContentType() {
return null;
}
- private final Map<QualifiedName, Object> properties = new HashMap<QualifiedName, Object>();
+ private final Map<QualifiedName, Object> properties = new HashMap<>();
+ @Override
public Object getProperty(QualifiedName key) {
return properties.get(key);
}
+ @Override
public boolean isRequested(QualifiedName key) {
return false;
}
+ @Override
public void setProperty(QualifiedName key, Object value) {
properties.put(key, value);
}
@@ -76,23 +83,27 @@
}
}
+ @Test
public void testSimple() {
assertValid("#!/bin/tclsh");
assertValid("#!/bin/expect");
assertValid("#!/bin/wish");
}
+ @Test
public void testEnv() {
assertValid("#!/usr/bin/env tclsh");
assertValid("#!/usr/bin/env expect");
assertValid("#!/usr/bin/env wish");
}
+ @Test
public void testExec1() {
assertValid("#!/bin/sh", "#\\",
"exec $AUTOTEST/bin/expect \"$0\" \"$@\"");
}
+ @Test
public void testExec2() {
assertValid("#!/bin/sh", "set me { $*", "shift", "shift",
"exec $AUTOTEST/bin/expect $0 $*");
diff --git a/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/core/tests/VariableResolverTests.java b/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/core/tests/VariableResolverTests.java
index e6aa9b0..d77ba17 100644
--- a/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/core/tests/VariableResolverTests.java
+++ b/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/core/tests/VariableResolverTests.java
@@ -1,38 +1,41 @@
/*******************************************************************************
- * Copyright (c) 2009 xored software, Inc.
+ * Copyright (c) 2009, 2017 xored software, Inc. and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* xored software, Inc. - initial API and Implementation (Alex Panchenko)
*******************************************************************************/
package org.eclipse.dltk.tcl.core.tests;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
-import junit.framework.TestCase;
-
import org.eclipse.dltk.tcl.internal.core.packages.TclVariableResolver;
import org.eclipse.dltk.tcl.internal.core.packages.TclVariableResolver.SimpleVariableRegistry;
+import org.junit.Test;
-@SuppressWarnings("nls")
-public class VariableResolverTests extends TestCase {
+public class VariableResolverTests {
private static TclVariableResolver createResolver() {
- return new TclVariableResolver(new SimpleVariableRegistry(Collections
- .<String, Object> emptyMap()));
+ return new TclVariableResolver(new SimpleVariableRegistry(
+ Collections.<String, Object> emptyMap()));
}
- private static TclVariableResolver createResolver(String key, Object value) {
- return new TclVariableResolver(new SimpleVariableRegistry(Collections
- .singletonMap(key, value)));
+ private static TclVariableResolver createResolver(String key,
+ Object value) {
+ return new TclVariableResolver(new SimpleVariableRegistry(
+ Collections.singletonMap(key, value)));
}
+ @Test
public void testNop() {
TclVariableResolver resolver = createResolver();
assertEquals(("a"), resolver.resolve("a"));
@@ -42,33 +45,38 @@
assertNull(resolver.resolve("$a(alfa)"));
}
+ @Test
public void testSingle() {
TclVariableResolver resolver = createResolver("name", "NAME");
assertEquals(("NAME"), resolver.resolve("$name"));
assertEquals(("NAME"), resolver.resolve("${name}"));
}
+ @Test
public void testSingleMixed() {
TclVariableResolver resolver = createResolver("name", "NAME");
assertEquals(("/NAME/"), resolver.resolve("/$name/"));
assertEquals(("/NAME/"), resolver.resolve("/${name}/"));
}
+ @Test
public void testComplex() {
TclVariableResolver resolver = createResolver("name", "VERY_VERY_BIG");
- assertEquals(("zaa/VERY_VERY_BIG/bbb"), resolver
- .resolve("zaa/$name/bbb"));
+ assertEquals(("zaa/VERY_VERY_BIG/bbb"),
+ resolver.resolve("zaa/$name/bbb"));
}
+ @Test
public void testSmaller() {
TclVariableResolver resolver = createResolver("longVariable", "small");
- assertEquals(("zaa/small/bbb"), resolver
- .resolve("zaa/$longVariable/bbb"));
+ assertEquals(("zaa/small/bbb"),
+ resolver.resolve("zaa/$longVariable/bbb"));
}
+ @Test
public void testEnvironmentResolve() {
- Map<String, String> envValues = new HashMap<String, String>();
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, String> envValues = new HashMap<>();
+ Map<String, Object> variables = new HashMap<>();
envValues.put("mytest", "myvalue");
variables.put("env", envValues);
variables.put("gamma", "mytest");
@@ -82,8 +90,9 @@
assertNull(resolver.resolve("$env($alpha)"));
}
+ @Test
public void testNestedExpressions() {
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
variables.put("a", "$b");
variables.put("b", "YES");
TclVariableResolver resolver = new TclVariableResolver(
@@ -91,8 +100,9 @@
assertEquals("YES", resolver.resolve("$a"));
}
+ @Test
public void testNestedCycle() {
- Map<String, Object> variables = new HashMap<String, Object>();
+ Map<String, Object> variables = new HashMap<>();
variables.put("a", "$b");
variables.put("b", "$a");
TclVariableResolver resolver = new TclVariableResolver(
diff --git a/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/core/tests/launching/TclPackagesTests.java b/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/core/tests/launching/TclPackagesTests.java
index accd050..5b22a4a 100644
--- a/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/core/tests/launching/TclPackagesTests.java
+++ b/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/core/tests/launching/TclPackagesTests.java
@@ -1,7 +1,5 @@
package org.eclipse.dltk.tcl.core.tests.launching;
-import junit.framework.Test;
-
import org.eclipse.core.runtime.Path;
import org.eclipse.dltk.core.environment.EnvironmentManager;
import org.eclipse.dltk.core.environment.IFileHandle;
@@ -12,6 +10,8 @@
import org.eclipse.dltk.launching.ScriptRuntime;
import org.eclipse.dltk.tcl.core.TclNature;
+import junit.framework.Test;
+
public class TclPackagesTests extends AbstractModelTests {
public TclPackagesTests(String name) {
diff --git a/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/core/tests/model/Activator.java b/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/core/tests/model/Activator.java
index 903a659..0e54749 100644
--- a/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/core/tests/model/Activator.java
+++ b/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/core/tests/model/Activator.java
@@ -1,11 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
+ * Copyright (c) 2005, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
-
*******************************************************************************/
package org.eclipse.dltk.tcl.core.tests.model;
@@ -22,7 +21,7 @@
// The shared instance
private static Activator plugin;
-
+
/**
* The constructor
*/
@@ -30,18 +29,12 @@
plugin = this;
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
- */
+ @Override
public void start(BundleContext context) throws Exception {
super.start(context);
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
- */
+ @Override
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
diff --git a/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/core/tests/model/AllTests.java b/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/core/tests/model/AllTests.java
index 667e3c1..530e57a 100644
--- a/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/core/tests/model/AllTests.java
+++ b/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/core/tests/model/AllTests.java
@@ -1,29 +1,18 @@
/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
+ * Copyright (c) 2005, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
-
*******************************************************************************/
package org.eclipse.dltk.tcl.core.tests.model;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+@RunWith(Suite.class)
+@Suite.SuiteClasses({ SearchTests.class, SearchVarTests.class,
+ TclSelectionTests.class, CompletionTests.class })
public class AllTests {
-
- public static Test suite() {
- TestSuite suite = new TestSuite(
- "Test for org.eclipse.dltk.tcl.core.tests.model");
- //$JUnit-BEGIN$
- suite.addTest(SearchTests.suite());
- suite.addTest(SearchVarTests.suite());
- suite.addTest(TclSelectionTests.suite());
- suite.addTest(CompletionTests.suite());
- //$JUnit-END$
- return suite;
- }
-
}
diff --git a/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/core/tests/model/CompletionTests.java b/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/core/tests/model/CompletionTests.java
index 6d08a8e..0c8b46d 100644
--- a/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/core/tests/model/CompletionTests.java
+++ b/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/core/tests/model/CompletionTests.java
@@ -1,33 +1,34 @@
/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
+ * Copyright (c) 2005, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
-
*******************************************************************************/
package org.eclipse.dltk.tcl.core.tests.model;
import java.util.Arrays;
-import junit.framework.Test;
-
import org.eclipse.dltk.codeassist.RelevanceConstants;
import org.eclipse.dltk.core.ISourceModule;
import org.eclipse.dltk.core.ModelException;
import org.eclipse.dltk.core.tests.model.AbstractModelCompletionTests;
import org.eclipse.dltk.core.tests.model.CompletionTestsRequestor;
+import junit.framework.Test;
+
public class CompletionTests extends AbstractModelCompletionTests {
private static final int RELEVANCE = (RelevanceConstants.R_DEFAULT
- + RelevanceConstants.R_INTERESTING + RelevanceConstants.R_CASE + RelevanceConstants.R_NON_RESTRICTED);
+ + RelevanceConstants.R_INTERESTING + RelevanceConstants.R_CASE
+ + RelevanceConstants.R_NON_RESTRICTED);
public CompletionTests(String name) {
super(Activator.PLUGIN_ID, name);
}
+ @Override
public void setUpSuite() throws Exception {
this.PROJECT = this.setUpScriptProject("Completion");
@@ -36,6 +37,7 @@
// 0);
}
+ @Override
public void tearDownSuite() throws Exception {
super.tearDownSuite();
// InternalDLTKLanguageManager.setPrefferedPriority(TclNature.NATURE_ID,
@@ -82,7 +84,7 @@
* Returns the location after the end of the line with the specified marker.
* This function is needed to compensate platform difference in line
* separators.
- *
+ *
* @param str
* @param marker
* @return
@@ -135,8 +137,8 @@
cu.codeComplete(cursorLocation, requestor);
assertEquals(this.makeResult(new String[] { "package",
- "package provide", "package require", "part" }), requestor
- .getResults());
+ "package provide", "package require", "part" }),
+ requestor.getResults());
}
@@ -149,9 +151,10 @@
int cursorLocation = newLineAfter(str, "#2") + 10;
cu.codeComplete(cursorLocation, requestor);
- assertEquals(this.makeResult(new String[] { "::a::c::fac()" },
- new String[] { "::a::c::fac" }, new int[] { 18 }), requestor
- .getResults());
+ assertEquals(
+ this.makeResult(new String[] { "::a::c::fac()" },
+ new String[] { "::a::c::fac" }, new int[] { 18 }),
+ requestor.getResults());
}
public void testCompletion004() throws ModelException {
@@ -163,10 +166,11 @@
int cursorLocation = newLineAfter(str, "#1") + 9;
cu.codeComplete(cursorLocation, requestor);
- assertEquals(this.makeResult(new String[] { "::a::c::fac()",
- "::a::c::fbac()", "::a::c::feac()" }, new String[] {
- "::a::c::fac", "::a::c::fbac", "::a::c::feac" }, new int[] {
- 18, 18, 18 }), requestor.getResults());
+ assertEquals(this.makeResult(
+ new String[] { "::a::c::fac()", "::a::c::fbac()",
+ "::a::c::feac()" },
+ new String[] { "::a::c::fac", "::a::c::fbac", "::a::c::feac" },
+ new int[] { 18, 18, 18 }), requestor.getResults());
}
@@ -188,8 +192,8 @@
}
int[] relevance = new int[result1.length];
Arrays.fill(relevance, RELEVANCE);
- assertEquals(this.makeResult(result1, result2, relevance), requestor
- .getResults());
+ assertEquals(this.makeResult(result1, result2, relevance),
+ requestor.getResults());
}
public void testCompletion006() throws ModelException {
@@ -201,9 +205,10 @@
int cursorLocation = newLineAfter(str, "#4") + 7;
cu.codeComplete(cursorLocation, requestor);
- assertEquals(this.makeResult(new String[] { "::b::fb()" },
- new String[] { "::b::fb" }, new int[] { 22 }), requestor
- .getResults());
+ assertEquals(
+ this.makeResult(new String[] { "::b::fb()" },
+ new String[] { "::b::fb" }, new int[] { 22 }),
+ requestor.getResults());
}
@@ -217,8 +222,8 @@
int cursorLocation = str.indexOf(s) + s.length();
cu.codeComplete(cursorLocation, requestor);
- assertEquals(this.makeResult(new String[] { "$::x", "$x" }, new int[] {
- 18, 18 }), requestor.getResults());
+ assertEquals(this.makeResult(new String[] { "$::x", "$x" },
+ new int[] { 18, 18 }), requestor.getResults());
}
@@ -231,8 +236,8 @@
int cursorLocation = newLineAfter(str, "puts \"");
cu.codeComplete(cursorLocation, requestor);
- assertEquals(this.makeResult(new String[] { "$::x", "$x" }, new int[] {
- 18, 18 }), requestor.getResults());
+ assertEquals(this.makeResult(new String[] { "$::x", "$x" },
+ new int[] { 18, 18 }), requestor.getResults());
}
@@ -245,8 +250,9 @@
int cursorLocation = newLineAfter(str, "#5") + 16;
cu.codeComplete(cursorLocation, requestor);
- assertEquals(this.makeResult(new String[] { "::a::c::fac()" },
- new String[] { "::a::c::fac" }, new int[] { 18 }), requestor
- .getResults());
+ assertEquals(
+ this.makeResult(new String[] { "::a::c::fac()" },
+ new String[] { "::a::c::fac" }, new int[] { 18 }),
+ requestor.getResults());
}
}
diff --git a/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/core/tests/model/PACompletionTests.java b/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/core/tests/model/PACompletionTests.java
index 76113bf..b391ba3 100644
--- a/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/core/tests/model/PACompletionTests.java
+++ b/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/core/tests/model/PACompletionTests.java
@@ -1,26 +1,25 @@
/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
+ * Copyright (c) 2005, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
-
*******************************************************************************/
package org.eclipse.dltk.tcl.core.tests.model;
import java.util.ArrayList;
import java.util.List;
-import junit.framework.Test;
-import junit.framework.TestCase;
-
import org.eclipse.dltk.core.CompletionProposal;
import org.eclipse.dltk.core.CompletionRequestor;
import org.eclipse.dltk.core.ISourceModule;
import org.eclipse.dltk.core.ModelException;
import org.eclipse.dltk.core.tests.model.AbstractModelCompletionTests;
+import junit.framework.Test;
+import junit.framework.TestCase;
+
public class PACompletionTests extends AbstractModelCompletionTests {
private static final String PROJECT_NAME = "PACompletion";
@@ -29,12 +28,14 @@
super(Activator.PLUGIN_ID, name);
}
+ @Override
public void setUpSuite() throws Exception {
this.PROJECT = this.setUpScriptProject(PROJECT_NAME);
super.setUpSuite();
waitUntilIndexesReady();
}
+ @Override
public void tearDownSuite() throws Exception {
super.tearDownSuite();
deleteProject(PROJECT_NAME);
@@ -46,8 +47,9 @@
private void testDo(String expected, String module, String pattern,
String project) throws ModelException {
- final List proposals = new ArrayList();
+ final List<CompletionProposal> proposals = new ArrayList<>();
CompletionRequestor requestor = new CompletionRequestor() {
+ @Override
public void accept(CompletionProposal proposal) {
proposals.add(proposal);
}
@@ -60,9 +62,9 @@
+ completeBehind.length();
cu.codeComplete(cursorLocation, requestor);
TestCase.assertEquals(1, proposals.size());
- CompletionProposal proposal = (CompletionProposal) proposals.get(0);
- TestCase.assertEquals(expected, proposal.getModelElement()
- .getHandleIdentifier());
+ CompletionProposal proposal = proposals.get(0);
+ TestCase.assertEquals(expected,
+ proposal.getModelElement().getHandleIdentifier());
}
public void testCompletion001() throws ModelException {
diff --git a/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/core/tests/model/PASelectionTests.java b/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/core/tests/model/PASelectionTests.java
index cc39699..9b68b37 100644
--- a/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/core/tests/model/PASelectionTests.java
+++ b/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/core/tests/model/PASelectionTests.java
@@ -1,22 +1,21 @@
/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
+ * Copyright (c) 2005, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
-
*******************************************************************************/
package org.eclipse.dltk.tcl.core.tests.model;
-import junit.framework.Test;
-import junit.framework.TestCase;
-
import org.eclipse.dltk.core.IModelElement;
import org.eclipse.dltk.core.ISourceModule;
import org.eclipse.dltk.core.ModelException;
import org.eclipse.dltk.core.tests.model.AbstractModelCompletionTests;
+import junit.framework.Test;
+import junit.framework.TestCase;
+
public class PASelectionTests extends AbstractModelCompletionTests {
private static final String PROJECT_NAME = "PASelection";
@@ -25,12 +24,14 @@
super(Activator.PLUGIN_ID, name);
}
+ @Override
public void setUpSuite() throws Exception {
this.PROJECT = this.setUpScriptProject(PROJECT_NAME);
super.setUpSuite();
waitUntilIndexesReady();
}
+ @Override
public void tearDownSuite() throws Exception {
super.tearDownSuite();
deleteProject(PROJECT_NAME);
@@ -59,8 +60,8 @@
}
public void testSelection001b() throws ModelException {
- testDo("=PASelection/pkg1<{module0.tcl[pkgnamespace~myproc",
- "test.tcl", "pkgnamespace::my", PROJECT_NAME);
+ testDo("=PASelection/pkg1<{module0.tcl[pkgnamespace~myproc", "test.tcl",
+ "pkgnamespace::my", PROJECT_NAME);
}
public void testSelection002() throws ModelException {
diff --git a/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/core/tests/model/SearchTests.java b/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/core/tests/model/SearchTests.java
index cff148e..6218258 100644
--- a/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/core/tests/model/SearchTests.java
+++ b/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/core/tests/model/SearchTests.java
@@ -1,11 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
+ * Copyright (c) 2005, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
-
*******************************************************************************/
package org.eclipse.dltk.tcl.core.tests.model;
@@ -24,8 +23,8 @@
import org.eclipse.dltk.core.tests.model.AbstractDLTKSearchTests;
import org.eclipse.dltk.core.tests.util.StringList;
-public class SearchTests extends AbstractDLTKSearchTests implements
- IDLTKSearchConstants {
+public class SearchTests extends AbstractDLTKSearchTests
+ implements IDLTKSearchConstants {
private static final String TCLSEARCH = "PROJ_TCLSearch";
private static final String TCLSEARCH2 = "PROJ_TCLSearch2";
@@ -37,11 +36,13 @@
return new Suite(SearchTests.class);
}
+ @Override
public void setUpSuite() throws Exception {
super.setUpSuite();
up();
}
+ @Override
public void tearDownSuite() throws Exception {
deleteProject(TCLSEARCH);
deleteProject(TCLSEARCH2);
@@ -73,8 +74,8 @@
public void testNamespaceDeclaration02() throws Exception {
up();
- IScriptFolder pkg = this.getScriptFolder(TCLSEARCH, "src", new Path(
- "p1"));
+ IScriptFolder pkg = this.getScriptFolder(TCLSEARCH, "src",
+ new Path("p1"));
IDLTKSearchScope scope = SearchEngine.createSearchScope(pkg);
search("Y", TYPE, DECLARATIONS, scope);
assertSearchResults("src/p1/test.tcl p1/Y", this.resultCollector);
@@ -130,8 +131,8 @@
public void testNamespaceDeclaration09() throws Exception {
up();
- IType type = getSourceModule(TCLSEARCH, "src", "p4/t.tcl").getType(
- "alfa");
+ IType type = getSourceModule(TCLSEARCH, "src", "p4/t.tcl")
+ .getType("alfa");
search(type, DECLARATIONS, getSearchScope(TCLSEARCH));
assertSearchResults("src/p4/t.tcl p4/alfa", resultCollector);
}
@@ -141,25 +142,22 @@
IDLTKSearchScope scope = SearchEngine
.createSearchScope(getScriptProject(TCLSEARCH));
search("*", METHOD, DECLARATIONS, scope);
- assertSearchResults(
- "src/X.tcl X$a()\n"
- + "src/p/X.tcl p/X$foo()\n"
- + "src/p1/test.tcl p1/Y$foo()\n"
- + "src/p2/X.tcl p2/X$foo()\n"
- + "src/p2/X.tcl p2/Y$foo()\n"
- + "src/p3/X.tcl p3/X$src_p3_X_X_function(arg1, arg2, arg3)\n"
- + "src/p3/X.tcl p3/X$foo()\n"
- + "src/p3/X.tcl p3/X$T1$src_p3_X_X_T1_function(arg1, arg2, arg3)\n"
- + "src/p3/X.tcl p3/X$T1$T1$src_p3_X_X_T1_T1_function(arg1, arg2, arg3)\n"
- + "src/p3/X.tcl p3/Y$src_p3_X_Y_function(arg1, arg2, arg3)\n"
- + "src/p3/X.tcl p3/Y$foo()\n"
- + "src/p3/X.tcl p3/Y$T2$T3$T4$src_p3_X_Y_T2_T3_T4_function(arg1, arg2, arg3)\n"
- + "src/p3/X.tcl p3/Z$foo()\n"
- + "src/p3/X.tcl $src_p3_X_function(arg1, arg2, arg3)\n"
- + "src/p3/X.tcl p3/global2$namespace2$function(arg1, arg2, arg3)\n"
- + "src/q5/AQ.tcl q5/I$k(arg)\n"
- + "src/q5/AQ.tcl q5/I2$k(arg)\n"
- + "src/q5/AQ.tcl $m()", this.resultCollector);
+ assertSearchResults("src/X.tcl X$a()\n" + "src/p/X.tcl p/X$foo()\n"
+ + "src/p1/test.tcl p1/Y$foo()\n" + "src/p2/X.tcl p2/X$foo()\n"
+ + "src/p2/X.tcl p2/Y$foo()\n"
+ + "src/p3/X.tcl p3/X$src_p3_X_X_function(arg1, arg2, arg3)\n"
+ + "src/p3/X.tcl p3/X$foo()\n"
+ + "src/p3/X.tcl p3/X$T1$src_p3_X_X_T1_function(arg1, arg2, arg3)\n"
+ + "src/p3/X.tcl p3/X$T1$T1$src_p3_X_X_T1_T1_function(arg1, arg2, arg3)\n"
+ + "src/p3/X.tcl p3/Y$src_p3_X_Y_function(arg1, arg2, arg3)\n"
+ + "src/p3/X.tcl p3/Y$foo()\n"
+ + "src/p3/X.tcl p3/Y$T2$T3$T4$src_p3_X_Y_T2_T3_T4_function(arg1, arg2, arg3)\n"
+ + "src/p3/X.tcl p3/Z$foo()\n"
+ + "src/p3/X.tcl $src_p3_X_function(arg1, arg2, arg3)\n"
+ + "src/p3/X.tcl p3/global2$namespace2$function(arg1, arg2, arg3)\n"
+ + "src/q5/AQ.tcl q5/I$k(arg)\n"
+ + "src/q5/AQ.tcl q5/I2$k(arg)\n" + "src/q5/AQ.tcl $m()",
+ this.resultCollector);
}
/**
@@ -201,8 +199,10 @@
IMethod method = type.getMethod("k");
search(method, REFERENCES, getSearchScope(TCLSEARCH));
- assertSearchResults("src/q5/AQ.tcl q5/I\n" + "src/q5/AQ.tcl $m()\n"
- + "src/q5/AQ.tcl\n" + "src/q5/AQ.tcl", this.resultCollector);
+ assertSearchResults(
+ "src/q5/AQ.tcl q5/I\n" + "src/q5/AQ.tcl $m()\n"
+ + "src/q5/AQ.tcl\n" + "src/q5/AQ.tcl",
+ this.resultCollector);
}
public void testMethodReference02() throws Exception {
@@ -212,8 +212,10 @@
new Path("q5/AQ.tcl")).getMethod("m");
search(method, REFERENCES, getSearchScope(TCLSEARCH));
- assertSearchResults("src/q5/AQ.tcl q5/I\n" + "src/q5/AQ.tcl q5/I2\n"
- + "src/q5/AQ.tcl\n" + "src/q5/AQ.tcl", this.resultCollector);
+ assertSearchResults(
+ "src/q5/AQ.tcl q5/I\n" + "src/q5/AQ.tcl q5/I2\n"
+ + "src/q5/AQ.tcl\n" + "src/q5/AQ.tcl",
+ this.resultCollector);
}
public void testTypeReference01() throws Exception {
@@ -231,10 +233,9 @@
.getType("I");
search(type, REFERENCES, getSearchScope(TCLSEARCH));
- assertSearchResults(
- "src/q5/AQ.tcl q5/I\n" + "src/q5/AQ.tcl q5/I2\n"
- + "src/q5/AQ.tcl $m()\n" + "src/q5/AQ.tcl\n"
- + "src/q5/AQ.tcl", this.resultCollector);
+ assertSearchResults("src/q5/AQ.tcl q5/I\n" + "src/q5/AQ.tcl q5/I2\n"
+ + "src/q5/AQ.tcl $m()\n" + "src/q5/AQ.tcl\n" + "src/q5/AQ.tcl",
+ this.resultCollector);
}
public void testVariableDeclaration01() throws Exception {
@@ -248,8 +249,8 @@
public void testVariableDeclaration02() throws Exception {
up();
- ISourceModule module = getSourceModule(TCLSEARCH, "src", new Path(
- "p3/X.tcl"));
+ ISourceModule module = getSourceModule(TCLSEARCH, "src",
+ new Path("p3/X.tcl"));
search("*", FIELD, DECLARATIONS, getSearchScope(TCLSEARCH));
assertSearchResults("src/p/X.tcl globalX\n"
diff --git a/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/core/tests/model/TclSelectionTests.java b/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/core/tests/model/TclSelectionTests.java
index 74c92ef..370f699 100644
--- a/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/core/tests/model/TclSelectionTests.java
+++ b/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/core/tests/model/TclSelectionTests.java
@@ -1,16 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
+ * Copyright (c) 2005, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
-
*******************************************************************************/
package org.eclipse.dltk.tcl.core.tests.model;
-import junit.framework.Test;
-
import org.eclipse.dltk.core.IField;
import org.eclipse.dltk.core.IMethod;
import org.eclipse.dltk.core.IModelElement;
@@ -18,6 +15,8 @@
import org.eclipse.dltk.core.ModelException;
import org.eclipse.dltk.core.tests.model.AbstractModelCompletionTests;
+import junit.framework.Test;
+
public class TclSelectionTests extends AbstractModelCompletionTests {
private static final String SELECTION_PROJECT = "TCL_Selection";
@@ -26,6 +25,7 @@
super(Activator.PLUGIN_ID, name);
}
+ @Override
public void setUpSuite() throws Exception {
PROJECT = setUpScriptProjectTo(SELECTION_PROJECT, "Selection");
@@ -33,6 +33,7 @@
waitUntilIndexesReady();
}
+ @Override
public void tearDownSuite() throws Exception {
deleteProject(SELECTION_PROJECT);
super.tearDownSuite();
@@ -206,8 +207,8 @@
IModelElement[] elements = cu.codeSelect(start, s.length());
assertNotNull(elements);
assertEquals(1, elements.length);
- IMethod method = cu.getType("a").getType("f").getType("q").getMethod(
- "faf_q");
+ IMethod method = cu.getType("a").getType("f").getType("q")
+ .getMethod("faf_q");
assertNotNull(method);
assertEquals(method, elements[0]);
}
@@ -226,8 +227,8 @@
IModelElement[] elements = cu.codeSelect(start, s.length());
assertNotNull(elements);
assertEquals(1, elements.length);
- IMethod method = cu.getType("a").getType("f").getType("q").getMethod(
- "fafq");
+ IMethod method = cu.getType("a").getType("f").getType("q")
+ .getMethod("fafq");
assertNotNull(method);
assertEquals(method, elements[0]);
}
@@ -687,8 +688,8 @@
String s = "puts $::a::f::q::vafq";
int i = 5;
IModelElement element = process028(cu, s, i, 0, s.length() - i);
- IField field = cu.getType("a").getType("f").getType("q").getField(
- "vafq");
+ IField field = cu.getType("a").getType("f").getType("q")
+ .getField("vafq");
assertEquals(field, element);
}
@@ -698,8 +699,8 @@
String s = "puts $::a::f::q::vafq2";
int i = 5;
IModelElement element = process028(cu, s, i, 0, s.length() - i);
- IField field = cu.getType("a").getType("f").getType("q").getField(
- "vafq2");
+ IField field = cu.getType("a").getType("f").getType("q")
+ .getField("vafq2");
assertEquals(field, element);
}
@@ -729,8 +730,8 @@
String s = "puts $::b::a::c::vca3";
int i = 5;
IModelElement element = process028(cu, s, i, 0, s.length() - i);
- IField field = cu.getType("b").getType("a").getType("c").getField(
- "vca3");
+ IField field = cu.getType("b").getType("a").getType("c")
+ .getField("vca3");
assertEquals(field, element);
}
diff --git a/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/parser/perfomance/tests/PeromanceTest0.java b/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/parser/perfomance/tests/PeromanceTest0.java
index 9442d13..1b83ff9 100644
--- a/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/parser/perfomance/tests/PeromanceTest0.java
+++ b/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/parser/perfomance/tests/PeromanceTest0.java
@@ -1,13 +1,11 @@
/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
+ * Copyright (c) 2005, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
-
*******************************************************************************/
-
package org.eclipse.dltk.tcl.parser.perfomance.tests;
import java.io.BufferedReader;
@@ -20,10 +18,7 @@
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
-import junit.framework.TestCase;
-
import org.eclipse.dltk.ast.declarations.ModuleDeclaration;
-import org.eclipse.dltk.ast.parser.ISourceParserConstants;
import org.eclipse.dltk.compiler.env.ModuleSource;
import org.eclipse.dltk.core.DLTKCore;
import org.eclipse.dltk.core.SourceParserUtil;
@@ -33,8 +28,11 @@
import org.eclipse.dltk.tcl.core.tests.model.Activator;
import org.eclipse.dltk.tcl.internal.core.search.mixin.TclMixinBuildVisitor;
import org.eclipse.dltk.tcl.internal.core.search.mixin.TclMixinParser;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
-public class PeromanceTest0 extends TestCase {
+public class PeromanceTest0 {
ZipFile scriptsZip = null;
private final static String[] scripts = new String[] { "append.tcl",
"appendComp.tcl", "assocd.tcl", "async.tcl", "autoMkindex.tcl",
@@ -95,15 +93,15 @@
return result.toString();
}
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setUp() throws Exception {
this.scriptsZip = new ZipFile(AbstractModelTests.storeToMetadata(
Activator.getDefault().getBundle(), "tcl_scripts.zip",
"/scripts/scripts.zip"));
}
- protected void tearDown() throws Exception {
- super.tearDown();
+ @After
+ public void tearDown() throws Exception {
if (this.scriptsZip != null) {
removeIfExist(this.scriptsZip.getName());
}
@@ -116,19 +114,16 @@
}
}
+ @Test
public void testPerfomance001() throws Exception {
if (this.scriptsZip == null) {
throw new IOException("Scripts not pressent...");
}
long start = System.currentTimeMillis();
- final List elements = new ArrayList();
+ final List<IMixinRequestor.ElementInfo> elements = new ArrayList<>();
TclMixinParser parser = new TclMixinParser();
- IMixinRequestor requestor = new IMixinRequestor() {
- public void reportElement(ElementInfo info) {
- elements.add(info);
- }
- };
+ IMixinRequestor requestor = info -> elements.add(info);
for (int number = 0; number < scripts.length; number++) {
String script = scripts[number];
InputStream input = null;
diff --git a/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/parser/structure/Collector.java b/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/parser/structure/Collector.java
index d176946..8d45738 100644
--- a/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/parser/structure/Collector.java
+++ b/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/parser/structure/Collector.java
@@ -1,10 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2009 xored software, Inc.
+ * Copyright (c) 2009, 2017 xored software, Inc. and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* xored software, Inc. - initial API and Implementation (Alex Panchenko)
@@ -21,8 +21,8 @@
import org.eclipse.dltk.compiler.SourceElementRequestorMode;
import org.eclipse.dltk.core.caching.StructureModelCollector;
-public class Collector extends StructureModelCollector implements
- ISourceElementRequestorExtension {
+public class Collector extends StructureModelCollector
+ implements ISourceElementRequestorExtension {
/**
* @param requestor
@@ -56,7 +56,7 @@
}
}
- final List<Tag> tags = new ArrayList<Tag>();
+ final List<Tag> tags = new ArrayList<>();
@Override
protected void writeTag(int tag) throws IOException {
@@ -130,6 +130,7 @@
// ignore
}
+ @Override
public SourceElementRequestorMode getMode() {
return SourceElementRequestorMode.STRUCTURE;
}
diff --git a/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/parser/structure/ParserInput.java b/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/parser/structure/ParserInput.java
index 5369693..78b544e 100644
--- a/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/parser/structure/ParserInput.java
+++ b/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/parser/structure/ParserInput.java
@@ -1,10 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2009 xored software, Inc.
+ * Copyright (c) 2009, 2017 xored software, Inc. and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* xored software, Inc. - initial API and Implementation (Alex Panchenko)
@@ -27,6 +27,7 @@
this.resource = resource;
}
+ @Override
public char[] getContentsAsCharArray() {
try {
final InputStream stream = resource.openConnection()
@@ -46,14 +47,17 @@
}
}
+ @Override
public IModelElement getModelElement() {
return null;
}
+ @Override
public String getSourceContents() {
return new String(getContentsAsCharArray());
}
+ @Override
public String getFileName() {
return resource.getPath();
}
diff --git a/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/parser/structure/SimpleStructureParserTests.java b/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/parser/structure/SimpleStructureParserTests.java
index ffa19ee..b80fa15 100644
--- a/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/parser/structure/SimpleStructureParserTests.java
+++ b/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/parser/structure/SimpleStructureParserTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 xored software, Inc.
+ * Copyright (c) 2010,2017 xored software, Inc. and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -14,19 +14,18 @@
import java.util.ArrayList;
import java.util.List;
-import junit.framework.Test;
-
import org.eclipse.core.runtime.Path;
import org.eclipse.dltk.core.DLTKCore;
import org.eclipse.dltk.core.IMethod;
import org.eclipse.dltk.core.IModelElement;
-import org.eclipse.dltk.core.IModelElementVisitor;
import org.eclipse.dltk.core.IParameter;
import org.eclipse.dltk.core.ISourceModule;
import org.eclipse.dltk.core.ModelException;
import org.eclipse.dltk.core.tests.model.AbstractModelTests;
import org.eclipse.dltk.tcl.core.tests.model.Activator;
+import junit.framework.Test;
+
public class SimpleStructureParserTests extends AbstractModelTests {
private static final String PROJECT_NAME = "Structure";
@@ -53,17 +52,15 @@
public void test1() throws ModelException {
final ISourceModule module = DLTKCore
- .createSourceModuleFrom(getProject(PROJECT_NAME).getFile(
- new Path("src/structure1.tcl")));
+ .createSourceModuleFrom(getProject(PROJECT_NAME)
+ .getFile(new Path("src/structure1.tcl")));
assertTrue(module.exists());
- final List<IMethod> methods = new ArrayList<IMethod>();
- module.accept(new IModelElementVisitor() {
- public boolean visit(IModelElement element) {
- if (element.getElementType() == IModelElement.METHOD) {
- methods.add((IMethod) element);
- }
- return true;
+ final List<IMethod> methods = new ArrayList<>();
+ module.accept(element -> {
+ if (element.getElementType() == IModelElement.METHOD) {
+ methods.add((IMethod) element);
}
+ return true;
});
assertEquals(1, methods.size());
assertEquals("hello", methods.get(0).getElementName());
diff --git a/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/parser/structure/StructureParserTests.java b/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/parser/structure/StructureParserTests.java
index 0748e42..ddc07eb 100644
--- a/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/parser/structure/StructureParserTests.java
+++ b/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/parser/structure/StructureParserTests.java
@@ -1,10 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2009, 2016 xored software, Inc and others.
+ * Copyright (c) 2009, 2017 xored software, Inc and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* xored software, Inc. - initial API and Implementation (Alex Panchenko)
@@ -20,10 +20,6 @@
import java.util.Enumeration;
import java.util.List;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
import org.eclipse.dltk.compiler.env.IModuleSource;
import org.eclipse.dltk.compiler.util.Util;
import org.eclipse.dltk.core.ISourceElementParser;
@@ -37,6 +33,10 @@
import org.eclipse.dltk.utils.TextUtils;
import org.osgi.framework.Bundle;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
public class StructureParserTests extends TestCase {
final URL resource;
@@ -50,7 +50,7 @@
* @param collector
*/
private String dump(Collector collector) {
- List<String> lines = new ArrayList<String>();
+ List<String> lines = new ArrayList<>();
final byte[] bytes = collector.getBytes();
final List<Tag> tags = collector.tags;
// lines.add(tags.toString());
@@ -130,13 +130,12 @@
}
public static Test suite() {
- return new StructureParserTests(null).createSuite(Activator
- .getDefault().getBundle(), "/", "*.tcl");
+ return new StructureParserTests(null)
+ .createSuite(Activator.getDefault().getBundle(), "/", "*.tcl");
}
public Test createSuite(Bundle bundle, String path, String pattern) {
TestSuite suite = new TestSuite(getClass().getName());
- @SuppressWarnings("unchecked")
Enumeration<URL> e = bundle.findEntries(path, pattern, true);
while (e.hasMoreElements()) {
URL url = e.nextElement();
diff --git a/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/parser/tests/AlgTests.java b/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/parser/tests/AlgTests.java
index 2edebf9..5ceafa9 100644
--- a/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/parser/tests/AlgTests.java
+++ b/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/parser/tests/AlgTests.java
@@ -1,65 +1,74 @@
/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
+ * Copyright (c) 2005, 207 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
-
*******************************************************************************/
package org.eclipse.dltk.tcl.parser.tests;
import org.eclipse.dltk.tcl.core.TclParseUtil;
+import org.junit.Test;
import junit.framework.TestCase;
-public class AlgTests extends TestCase {
-
+public class AlgTests {
+ @Test
public void test001() {
String s = "";
check(s);
}
+ @Test
public void test002() {
String s = "a:b";
check(s);
}
+ @Test
public void test003() {
String s = "a::b";
check(s);
}
+ @Test
public void test004() {
String s = "::a:b";
check(s);
}
+ @Test
public void test005() {
String s = "a:b";
check(s);
}
+ @Test
public void test006() {
String s = "a:b::";
check(s);
}
+ @Test
public void test007() {
String s = "a::b::c";
check(s);
}
+ @Test
public void test008() {
String s = "a:::b";
check(s);
}
+ @Test
public void test009() {
String s = "a::b:::";
check(s);
}
+ @Test
public void test00() {
String s = ":::a::b";
check(s);
diff --git a/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/parser/tests/AllParseTests.java b/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/parser/tests/AllParseTests.java
index 468a094..ab705f5 100644
--- a/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/parser/tests/AllParseTests.java
+++ b/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/parser/tests/AllParseTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
+ * Copyright (c) 2005, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -15,9 +15,6 @@
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
import org.eclipse.dltk.ast.declarations.ModuleDeclaration;
import org.eclipse.dltk.ast.parser.ISourceParser;
import org.eclipse.dltk.compiler.env.ModuleSource;
@@ -32,6 +29,9 @@
import org.eclipse.dltk.tcl.parser.definitions.DefinitionManager;
import org.eclipse.dltk.tcl.parser.definitions.NamespaceScopeProcessor;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
public class AllParseTests extends TestCase {
static final String CHARSET = "ISO-8859-1"; //$NON-NLS-1$
@@ -40,15 +40,15 @@
public static TestSuite suite() {
final TestSuite suite = new TestSuite(AllParseTests.class.getName());
- final URL scripts = Activator.getDefault().getBundle().getEntry(
- SCRIPTS_ZIP);
+ final URL scripts = Activator.getDefault().getBundle()
+ .getEntry(SCRIPTS_ZIP);
if (scripts == null) {
suite.addTest(new TestCase("error") { //$NON-NLS-1$
- @Override
- protected void runTest() throws Throwable {
- fail(SCRIPTS_ZIP + " is not found"); //$NON-NLS-1$
- }
- });
+ @Override
+ protected void runTest() throws Throwable {
+ fail(SCRIPTS_ZIP + " is not found"); //$NON-NLS-1$
+ }
+ });
} else {
try {
final ZipInputStream zipInputStream = new ZipInputStream(
@@ -74,16 +74,16 @@
try {
zipInputStream.close();
} catch (IOException e) {
- //
+ //
}
}
} catch (final IOException e) {
suite.addTest(new TestCase("IOException") { //$NON-NLS-1$
- @Override
- protected void runTest() throws Throwable {
- throw e;
- }
- });
+ @Override
+ protected void runTest() throws Throwable {
+ throw e;
+ }
+ });
}
}
return suite;
@@ -103,8 +103,8 @@
final ISourceParser parser = DLTKLanguageManager
.getSourceParser(TclNature.NATURE_ID);
long s1 = System.currentTimeMillis();
- ModuleDeclaration module1 = (ModuleDeclaration) parser.parse(
- new ModuleSource(content), collector);
+ ModuleDeclaration module1 = (ModuleDeclaration) parser
+ .parse(new ModuleSource(content), collector);
long e1 = System.currentTimeMillis();
// if (collector.hasErrors()) {
// fail(collector.getErrors().toString());
diff --git a/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/parser/tests/AllTests.java b/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/parser/tests/AllTests.java
index 002e02a..ca87a6b 100644
--- a/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/parser/tests/AllTests.java
+++ b/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/parser/tests/AllTests.java
@@ -1,29 +1,19 @@
/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
+ * Copyright (c) 2005, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
-
*******************************************************************************/
package org.eclipse.dltk.tcl.parser.tests;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+@RunWith(Suite.class)
+@Suite.SuiteClasses({ AllParseTests.class, SimpleParserTests.class,
+ TclIfProcessorTests.class, TclParseUtilTests.class })
public class AllTests {
- public static Test suite() {
- TestSuite suite = new TestSuite(
- "Test for org.eclipse.dltk.tcl.parser.tests"); //$NON-NLS-1$
- // $JUnit-BEGIN$
- suite.addTest(AllParseTests.suite());
- suite.addTestSuite(SimpleParserTests.class);
- suite.addTestSuite(TclIfProcessorTests.class);
- suite.addTestSuite(TclParseUtilTests.class);
- // $JUnit-END$
- return suite;
- }
-
}
diff --git a/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/parser/tests/NewTclParserTests.java b/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/parser/tests/NewTclParserTests.java
index 6a9b44d..615157a 100644
--- a/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/parser/tests/NewTclParserTests.java
+++ b/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/parser/tests/NewTclParserTests.java
@@ -2,16 +2,18 @@
import java.util.List;
-import junit.framework.TestCase;
-
import org.eclipse.dltk.ast.ASTNode;
import org.eclipse.dltk.ast.declarations.MethodDeclaration;
import org.eclipse.dltk.ast.declarations.ModuleDeclaration;
import org.eclipse.dltk.compiler.env.ModuleSource;
import org.eclipse.dltk.tcl.internal.parser.NewTclSourceParser;
import org.eclipse.dltk.tcl.internal.parser.TclSourceParser;
+import org.junit.Test;
-public class NewTclParserTests extends TestCase {
+import junit.framework.TestCase;
+
+public class NewTclParserTests {
+ @Test
public void test001() throws Exception {
String content = "proc alfa { alfa { beta } } {}";
TclSourceParser oldParser = new TclSourceParser();
diff --git a/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/parser/tests/SimpleParserTests.java b/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/parser/tests/SimpleParserTests.java
index bc6f233..a0c4d88 100644
--- a/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/parser/tests/SimpleParserTests.java
+++ b/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/parser/tests/SimpleParserTests.java
@@ -1,22 +1,21 @@
/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
+ * Copyright (c) 2005, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
-
*******************************************************************************/
package org.eclipse.dltk.tcl.parser.tests;
+import static org.junit.Assert.assertEquals;
+
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.net.MalformedURLException;
import java.net.URL;
import java.util.Enumeration;
-import java.util.Iterator;
import java.util.List;
import javax.xml.parsers.DocumentBuilder;
@@ -24,8 +23,6 @@
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
-import junit.framework.TestCase;
-
import org.eclipse.dltk.core.tests.xml.DOMSerializer;
import org.eclipse.dltk.launching.LaunchingMessages;
import org.eclipse.dltk.tcl.core.tests.model.Activator;
@@ -39,6 +36,7 @@
import org.eclipse.dltk.tcl.internal.parser.raw.TclScript;
import org.eclipse.dltk.tcl.internal.parser.raw.TclWord;
import org.eclipse.dltk.tcl.internal.parser.raw.VariableSubstitution;
+import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -46,7 +44,7 @@
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
-public class SimpleParserTests extends TestCase {
+public class SimpleParserTests {
private String getContents(URL url) throws IOException {
InputStream input = null;
@@ -70,11 +68,10 @@
}
private void print(TclWord s) {
- System.out.println(" - - word from " + s.getStart() + " to "
- + s.getEnd());
- List cmd = s.getContents();
- for (Iterator iter = cmd.iterator(); iter.hasNext();) {
- Object o = iter.next();
+ System.out.println(
+ " - - word from " + s.getStart() + " to " + s.getEnd());
+ List<?> cmd = s.getContents();
+ for (Object o : cmd) {
System.out.println(" - - - " + o.toString());
if (o instanceof CommandSubstitution) {
System.out.println("# internal script #");
@@ -85,23 +82,21 @@
}
private void print(TclCommand s) {
- System.out.println(" - command from " + s.getStart() + " to "
- + s.getEnd());
- List cmd = s.getWords();
- for (Iterator iter = cmd.iterator(); iter.hasNext();) {
- TclWord word = (TclWord) iter.next();
+ System.out.println(
+ " - command from " + s.getStart() + " to " + s.getEnd());
+ List<TclWord> cmd = s.getWords();
+ for (TclWord word : cmd) {
print(word);
}
}
private void print(TclScript s) {
System.out.println("script from " + s.getStart() + " to " + s.getEnd());
- List cmd = s.getCommands();
- for (Iterator iter = cmd.iterator(); iter.hasNext();) {
- TclCommand c = (TclCommand) iter.next();
+ List<TclCommand> cmd = s.getCommands();
+ for (TclCommand c : cmd) {
if (c == null)
- System.out
- .println("comment(AND ERROR TOO, no null ptr should be in result) here!");
+ System.out.println(
+ "comment(AND ERROR TOO, no null ptr should be in result) here!");
else
print(c);
}
@@ -109,7 +104,7 @@
/**
* Returns a Document that can be used to build a DOM tree
- *
+ *
* @return the Document
* @throws ParserConfigurationException
* if an exception occurs creating the document builder
@@ -124,13 +119,13 @@
/**
* Serializes a XML document into a string - encoded in UTF8 format, with
* platform line separators.
- *
+ *
* @param doc
* document to serialize
* @return the document as a string
*/
- public static String serializeDocument(Document doc) throws IOException,
- TransformerException {
+ public static String serializeDocument(Document doc)
+ throws IOException, TransformerException {
return new DOMSerializer().serialize(doc).trim();
}
@@ -151,10 +146,12 @@
parser.setErrorHandler(new DefaultHandler());
doc = parser.parse(new InputSource(stream));
} catch (SAXException e) {
- throw new IOException(LaunchingMessages.ScriptRuntime_badFormat);
+ throw new IOException(
+ LaunchingMessages.ScriptRuntime_badFormat);
} catch (ParserConfigurationException e) {
stream.close();
- throw new IOException(LaunchingMessages.ScriptRuntime_badFormat);
+ throw new IOException(
+ LaunchingMessages.ScriptRuntime_badFormat);
} finally {
stream.close();
}
@@ -179,13 +176,12 @@
Element w = doc.createElement("word");
w.setAttribute("start", Integer.toString(word.getStart()));
w.setAttribute("end", Integer.toString(word.getEnd()));
- String wordRawText = getCodeRange(source, word.getStart(), word
- .getEnd());
+ String wordRawText = getCodeRange(source, word.getStart(),
+ word.getEnd());
w.setAttribute("text", wordRawText);
- List parts = word.getContents();
- for (Iterator wordIter = parts.iterator(); wordIter.hasNext();) {
- Object o = wordIter.next();
+ List<?> parts = word.getContents();
+ for (Object o : parts) {
Element p = null;
if (o instanceof String) {
p = doc.createElement("string");
@@ -202,20 +198,22 @@
} else if (o instanceof QuotesSubstitution) {
p = doc.createElement("quotes");
// String rawText = ((QuotesSubstitution)o).getRawText();
- String rawText = getCodeRange(source, ((QuotesSubstitution) o)
- .getStart(), ((QuotesSubstitution) o).getEnd());
+ String rawText = getCodeRange(source,
+ ((QuotesSubstitution) o).getStart(),
+ ((QuotesSubstitution) o).getEnd());
if (rawText == null)
- throw new NullPointerException(o.toString()
- + " has null raw text");
+ throw new NullPointerException(
+ o.toString() + " has null raw text");
p.setAttribute("text", rawText);
} else if (o instanceof BracesSubstitution) {
p = doc.createElement("braces");
// String rawText = ((BracesSubstitution)o).getRawText();
- String rawText = getCodeRange(source, ((BracesSubstitution) o)
- .getStart(), ((BracesSubstitution) o).getEnd());
+ String rawText = getCodeRange(source,
+ ((BracesSubstitution) o).getStart(),
+ ((BracesSubstitution) o).getEnd());
if (rawText == null)
- throw new NullPointerException(o.toString()
- + " has null raw text");
+ throw new NullPointerException(
+ o.toString() + " has null raw text");
p.setAttribute("text", rawText);
} else if (o instanceof VariableSubstitution) {
p = doc.createElement("variable");
@@ -224,8 +222,8 @@
p.setAttribute("end", Integer.toString(vs.getEnd()));
p.setAttribute("kind", Integer.toString(vs.getKind()));
if (vs.getName() == null)
- throw new NullPointerException(o.toString()
- + " has null name");
+ throw new NullPointerException(
+ o.toString() + " has null name");
p.setAttribute("name", vs.getName());
if (vs.getIndex() != null)
p.appendChild(getWordAsNode(source, vs.getIndex(), doc));
@@ -237,8 +235,8 @@
((NormalBackslashSubstitution) o).getStart(),
((NormalBackslashSubstitution) o).getEnd());
if (rawText == null)
- throw new NullPointerException(o.toString()
- + " has null raw text");
+ throw new NullPointerException(
+ o.toString() + " has null raw text");
p.setAttribute("text", rawText);
} else if (o instanceof MagicBackslashSubstitution) {
p = doc.createElement("newlinebs");
@@ -251,16 +249,14 @@
private Node getXML(String source, TclScript s, Document doc) {
Element script = doc.createElement("script");
doc.appendChild(script);
- List cmd = s.getCommands();
- for (Iterator iter = cmd.iterator(); iter.hasNext();) {
- TclCommand c = (TclCommand) iter.next();
+ List<TclCommand> cmd = s.getCommands();
+ for (TclCommand c : cmd) {
Element command = doc.createElement("command");
command.setAttribute("start", Integer.toString(c.getStart()));
command.setAttribute("end", Integer.toString(c.getEnd()));
script.appendChild(command);
- List words = c.getWords();
- for (Iterator cmdIter = words.iterator(); cmdIter.hasNext();) {
- TclWord word = (TclWord) cmdIter.next();
+ List<TclWord> words = c.getWords();
+ for (TclWord word : words) {
Node w = getWordAsNode(source, word, doc);
command.appendChild(w);
}
@@ -273,10 +269,7 @@
try {
xml = serializeDocument(createXMLFromSource(source, result));
System.out.println(xml);
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (TransformerException e) {
+ } catch (IOException | TransformerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
@@ -298,109 +291,129 @@
assertEquals(expectedXML, resultXML);
- } catch (MalformedURLException e) {
- e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
public void _testAll() throws Exception {
- Enumeration e = Activator.getDefault().getBundle().getEntryPaths(
- "rawtests/");
+ Enumeration<String> e = Activator.getDefault().getBundle()
+ .getEntryPaths("rawtests/");
while (e.hasMoreElements()) {
- Object o = e.nextElement();
+ String o = e.nextElement();
System.out.println("found test " + o);
// runTestOn ((new Path(o.toString())).lastSegment());
- runTestOn(o.toString());
+ runTestOn(o);
}
}
+ @Test
public void test0() throws Exception {
runTestOn("rawtests/0.tcl");
}
+ @Test
public void test1() throws Exception {
runTestOn("rawtests/1.tcl");
}
+ @Test
public void test2() throws Exception {
runTestOn("rawtests/2.tcl");
}
+ @Test
public void test3() throws Exception {
runTestOn("rawtests/3.tcl");
}
+ @Test
public void test4() throws Exception {
runTestOn("rawtests/4.tcl");
}
+ @Test
public void test5() throws Exception {
runTestOn("rawtests/5.tcl");
}
+ @Test
public void test6() throws Exception {
runTestOn("rawtests/6.tcl");
}
+ @Test
public void test7() throws Exception {
runTestOn("rawtests/simple0.tcl");
}
+ @Test
public void test8() throws Exception {
runTestOn("rawtests/simple1.tcl");
}
+ @Test
public void test9() throws Exception {
runTestOn("rawtests/simple3.tcl");
}
+ @Test
public void test10() throws Exception {
runTestOn("rawtests/all.tcl");
}
+ @Test
public void test11() throws Exception {
runTestOn("rawtests/a.tcl");
}
+ @Test
public void test12() throws Exception {
String content = "\r\n puts $a ; puts \"wow!\"\r";
SimpleTclParser.staticParse(content);
}
+ @Test
public void test13() throws Exception {
runTestOn("rawtests/7.tcl");
}
+ @Test
public void test14() throws Exception {
runTestOn("rawtests/8.tcl");
}
+ @Test
public void test15() throws Exception {
runTestOn("rawtests/9.tcl");
}
+ @Test
public void test16() throws Exception {
runTestOn("rawtests/b.tcl");
}
+ @Test
public void test17() throws Exception {
runTestOn("rawtests/c.tcl");
}
+ @Test
public void test18() throws Exception {
runTestOn("rawtests/d.tcl");
}
+ @Test
public void test19() throws Exception {
runTestOn("rawtests/e.tcl");
}
+ @Test
public void test20() throws Exception {
runTestOn("rawtests/f.tcl");
}
+ @Test
public void test21() throws Exception {
runTestOn("rawtests/g.tcl");
}
diff --git a/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/parser/tests/TclParseUtilTests.java b/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/parser/tests/TclParseUtilTests.java
index 457481d..7f8e8aa 100644
--- a/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/parser/tests/TclParseUtilTests.java
+++ b/tcl/tests/org.eclipse.dltk.tcl.core.tests/src/org/eclipse/dltk/tcl/parser/tests/TclParseUtilTests.java
@@ -1,31 +1,32 @@
/*******************************************************************************
- * Copyright (c) 2009 xored software, Inc.
+ * Copyright (c) 2009, 2017 xored software, Inc. and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
+ * http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* xored software, Inc. - initial API and Implementation (Alex Panchenko)
*******************************************************************************/
package org.eclipse.dltk.tcl.parser.tests;
+import static org.junit.Assert.assertEquals;
+
import org.eclipse.dltk.tcl.core.TclParseUtil;
+import org.junit.Test;
-import junit.framework.TestCase;
+public class TclParseUtilTests {
-@SuppressWarnings("nls")
-public class TclParseUtilTests extends TestCase {
-
+ @Test
public void testEscapeName() {
assertEquals("A", TclParseUtil.escapeName("A"));
assertEquals("\\u0A", TclParseUtil.escapeName("\n"));
assertEquals("{A }", TclParseUtil.escapeName("A "));
assertEquals("{ A }", TclParseUtil.escapeName(" A "));
assertEquals("{ }", TclParseUtil.escapeName(" "));
- assertEquals("Hello world", TclParseUtil.escapeName("Hello\\" + "\n"
- + " world"));
+ assertEquals("Hello world",
+ TclParseUtil.escapeName("Hello\\" + "\n" + " world"));
}
}