| /******************************************************************************* |
| * Copyright (c) 2009 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 |
| * |
| * Contributors: IBM Corporation - initial API and implementation |
| *******************************************************************************/ |
| package org.eclipse.e4.languages.javascript.junit.test; |
| |
| import java.io.File; |
| import java.io.IOException; |
| import java.net.URI; |
| import java.net.URISyntaxException; |
| import java.net.URL; |
| |
| import org.eclipse.core.runtime.FileLocator; |
| import org.eclipse.e4.languages.javascript.junit.JavaScriptTestCase; |
| |
| public class BasicJavaScriptTest extends JavaScriptTestCase { |
| |
| public BasicJavaScriptTest() { |
| this(null); |
| } |
| |
| public BasicJavaScriptTest(String name) { |
| super(name, null); |
| useJavaTests(); |
| } |
| |
| |
| |
| public void testBasics() { |
| eval("var x = 7;"); |
| eval("assertTrue(null, typeof x == 'number');"); |
| eval("assertTrue('test', true);"); |
| eval("assertTrue(true);"); |
| } |
| |
| public void testBasics2() throws URISyntaxException { |
| URL test2jsURL = getClass().getResource("test2.js"); |
| eval(readContents(test2jsURL), test2jsURL.toURI().toString()); |
| eval("assertEquals('farleysmoke',farleysmoke);"); |
| } |
| |
| public void testBasics3() throws URISyntaxException, IOException { |
| URL test2jsURL = getClass().getResource("test2.js"); |
| File test2jsFile = new File(FileLocator.toFileURL(test2jsURL).toURI()); |
| eval(readContents(test2jsURL), test2jsFile.getAbsolutePath()); |
| eval("assertEquals('farleysmoke',farleysmoke);"); |
| } |
| |
| public void testBasics4() throws URISyntaxException, IOException { |
| URL test2jsURL = getClass().getResource("test2.js"); |
| File test2jsFile = new File(FileLocator.toFileURL(test2jsURL).toURI()); |
| eval(readContents(test2jsURL), test2jsFile.toURI().toString()); |
| eval("assertEquals('farleysmoke',farleysmoke);"); |
| } |
| |
| public void testBasics5() throws URISyntaxException, IOException { |
| URL test2jsURL = getClass().getResource("test2.js"); |
| eval(readContents(test2jsURL), "org.eclipse.e4.languages.javascript.junit.test/src/org/eclipse/e4/languages/javascript/junit/test/test2.js"); |
| eval("assertEquals('farleysmoke',farleysmoke);"); |
| } |
| |
| public void testBasics6() throws URISyntaxException, IOException { |
| URL test2jsURL = getClass().getResource("test2.js"); |
| File test2jsFile = new File("C:\\workspaces\\runtime-New_configuration\\org.eclipse.e4.languages.javascript.junit.test\\src\\org\\eclipse\\e4\\languages\\javascript\\junit\\test\\test2.js"); |
| eval(readContents(test2jsURL), test2jsFile.toURI().toString()); |
| eval("assertEquals('farleysmoke',farleysmoke);"); |
| } |
| } |