view src/org/RhinoTests/JavaScriptSnippets.java @ 352:9b40969f01e3 draft

Added new tests into CompiledScriptTest.
author Pavel Tisnovsky <ptisnovs@redhat.com>
date Thu, 10 Apr 2014 11:05:49 +0200
parents 48afda73ee6e
children
line wrap: on
line source

/*
  Rhino test framework

   Copyright (C) 2012, 2013, 2014  Red Hat

This file is part of IcedTea.

IcedTea is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.

IcedTea is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License
along with IcedTea; see the file COPYING.  If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.

Linking this library statically or dynamically with other modules is
making a combined work based on this library.  Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.

As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module.  An independent module is a module which is not derived from
or based on this library.  If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so.  If you do not wish to do so, delete this
exception statement from your version.
*/

package org.RhinoTests;

/**
 * Short JavaScript snippets stored in strings.
 * 
 * @author Pavel Tisnovsky
 */
public class JavaScriptSnippets {

    /**
     * Empty, but still valid script.
     */
    protected static final String EMPTY_SCRIPT_1 = "";

    /**
     * Almost empty, but still valid script.
     */
    protected static final String EMPTY_SCRIPT_2 = " ";

    /**
     * Almost empty, but still valid script.
     */
    protected static final String EMPTY_SCRIPT_3 = "\t";

    /**
     * Almost empty, but still valid script.
     */
    protected static final String EMPTY_SCRIPT_4 = " \t";

    /**
     * Almost empty, but still valid script.
     */
    protected static final String EMPTY_SCRIPT_5 = " \t ";

    /**
     * Almost empty, but still valid script.
     */
    protected static final String EMPTY_SCRIPT_6 = " \t \t ";

    /**
     * Almost empty, but still valid script.
     */
    protected static final String EMPTY_SCRIPT_7 = "\n";

    /**
     * Almost empty, but still valid script.
     */
    protected static final String EMPTY_SCRIPT_8 = "\n\n";

    /**
     * Almost empty, but still valid script.
     */
    protected static final String EMPTY_SCRIPT_9 = "\n\t";

    /**
     * Almost empty, but still valid script.
     */
    protected static final String EMPTY_SCRIPT_10 = "\t\n";

    /**
     * Almost empty, but still valid script.
     */
    protected static final String EMPTY_SCRIPT_11 = "\t\n\t";

    /**
     * Almost empty, but still valid script.
     */
    protected static final String EMPTY_SCRIPT_12 = "\n \n";

    /**
     * Almost empty, but still valid script.
     */
    protected static final String EMPTY_SCRIPT_13 = " \n \n";

    /**
     * Almost empty, but still valid script.
     */
    protected static final String EMPTY_SCRIPT_14 = "\n \n ";

    /**
     * Numeric expression.
     */
    protected static final String NUMERIC_EXPRESSION_0 = "42";

    /**
     * Numeric expression.
     */
    protected static final String NUMERIC_EXPRESSION_1 = "1+2";

    /**
     * Numeric expression.
     */
    protected static final String NUMERIC_EXPRESSION_2 = "1+2+3";

    /**
     * Numeric expression.
     */
    protected static final String NUMERIC_EXPRESSION_3 = "1+2*3";

    /**
     * Numeric expression.
     */
    protected static final String NUMERIC_EXPRESSION_4 = "1*2+3";

    /**
     * Numeric expression.
     */
    protected static final String NUMERIC_EXPRESSION_5 = "1+(2*3)";

    /**
     * Numeric expression.
     */
    protected static final String NUMERIC_EXPRESSION_6 = "(1+2)*3";

    /**
     * Numeric expression.
     */
    protected static final String NUMERIC_EXPRESSION_7 = "(42)";

    /**
     * Numeric expression.
     */
    protected static final String NUMERIC_EXPRESSION_8 = "((42))";

    /**
     * Numeric expression.
     */
    protected static final String NUMERIC_EXPRESSION_9 = "((1+2))";

    /**
     * Numeric expression.
     */
    protected static final String NUMERIC_EXPRESSION_10 = "((1+2+3))";

    /**
     * Numeric expression containing floating point value.
     */
    protected static final String DOUBLE_NUMERIC_EXPRESSION_1 = "1./2";

    /**
     * Numeric expression containing floating point value.
     */
    protected static final String DOUBLE_NUMERIC_EXPRESSION_2 = "1/2.";

    /**
     * Numeric expression containing floating point value.
     */
    protected static final String DOUBLE_NUMERIC_EXPRESSION_3 = "1./2.";

    /**
     * Boolean expression containing simple boolean value.
     */
    protected static final String BOOLEAN_EXPRESSION_1 = "true";

    /**
     * Boolean expression containing simple boolean value.
     */
    protected static final String BOOLEAN_EXPRESSION_2 = "false";

    /**
     * Boolean expression.
     */
    protected static final String BOOLEAN_EXPRESSION_3 = "! true";

    /**
     * Boolean expression.
     */
    protected static final String BOOLEAN_EXPRESSION_4 = "! false";

    /**
     * String expression (containing only string literal).
     */
    protected static final String STRING_EXPRESSION_1 = "'Hello'";

    /**
     * String expression.
     */
    protected static final String STRING_EXPRESSION_2 = "'Hello' + ' ' + 'world'";

    /**
     * Classical hello world program.
     */
    protected static final String HELLO_WORLD_1 = "println('\tHello world!')";

    /**
     * Slightly modified hello world program. 
     */
    protected static final String HELLO_WORLD_2 = "println('\tHello' + ' world!')";

    /**
     * Slightly modified hello world program. 
     */
    protected static final String HELLO_WORLD_3 = "println('\tHello' + ' ' + 'world!')";

    /**
     * Slightly modified hello world program. 
     */
    protected static final String HELLO_WORLD_4 = "println('\tHello' + '\t' + 'world!')";

    /**
     * Statement containing unknown function. 
     */
    protected static final String UNKNOWN_FUNCTION = "_unknown_function_('\tHello world!')";

    /**
     * Statement containing unknown function. 
     */
    protected static final String UNKNOWN_FUNCTION_2 = "_()";
}