rhino1.7.6.testsrc.tests.e4x.Expressions.11.4.1.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rhino Show documentation
Show all versions of rhino Show documentation
Rhino is an open-source implementation of JavaScript written entirely in Java. It is typically
embedded into Java applications to provide scripting to end users.
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
gTestfile = '11.4.1.js';
START("11.4.1 - Addition Operator");
employeeData = Fred + 28 + skiing ;
TEST(1, "xml", typeof(employeeData));
correct = <>Fred 28 skiing >;
TEST(2, correct, employeeData);
order =
-
Big Screen Television
-
DVD Player
-
CD Player
-
8-Track Player
;
correct =
Big Screen Television +
CD Player +
8-Track Player ;
myItems = order.item[0] + order.item[2] + order.item[3];
TEST(3, "xml", typeof(myItems));
TEST(4, correct, myItems);
correct =
Big Screen Television +
DVD Player +
CD Player +
8-Track Player +
New Item ;
newItems = order.item + New Item ;
TEST(5, "xml", typeof(newItems));
TEST(6, correct, newItems);
order =
-
Big Screen Television
1299.99
-
DVD Player
399.99
-
CD Player
199.99
-
8-Track Player
69.99
;
totalPrice = +order.item[0].price + +order.item[1].price;
TEST(7, "number", typeof(totalPrice));
TEST(8, 1699.98, totalPrice);
totalPrice = Number(order.item[1].price) + Number(order.item[3].price);
TEST(9, 469.98, totalPrice);
order =
123 Foobar Ave.
Bellevue
WA
98008
;
streetCity = "" + order.customer.address.street + order.customer.address.city;
TEST(10, "string", typeof(streetCity));
TEST(11, "123 Foobar Ave.Bellevue", streetCity);
statezip = String(order.customer.address.state) + order.customer.address.zip;
TEST(12, "string", typeof(statezip));
TEST(13, "WA98008", statezip);
END();
© 2015 - 2024 Weber Informatics LLC | Privacy Policy