All Downloads are FREE. Search and download functionalities are using the official Maven repository.

rhino1.7.7.testsrc.tests.e4x.Expressions.11.6.1.js Maven / Gradle / Ivy

Go to download

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.

There is a newer version: 1.7.15
Show newest version
/* -*- 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.6.1.js';

START("11.6.1 - XML Assignment");

// Change the value of the id attribute on the second item
order =

    
        Big Screen Television
        1299.99
    
    
        DVD Player
        399.99
    
    
        CD Player
        199.99
    
    
        8-Track Player
        69.99
    
;

correct =

    
        Big Screen Television
        1299.99
    
    
        DVD Player
        399.99
    
    
        CD Player
        199.99
    
    
        8-Track Player
        69.99
    
;

order.item[1].@id = 1.23;
TEST(1, correct, order);

// Add a new attribute to the second item
order =

    
        Big Screen Television
        1299.99
    
    
        DVD Player
        399.99
    
    
        CD Player
        199.99
    
    
        8-Track Player
        69.99
    
;

correct =

    
        Big Screen Television
        1299.99
    
    
        DVD Player
        399.99
    
    
        CD Player
        199.99
    
    
        8-Track Player
        69.99
    
;

order.item[1].@newattr = "new value";
TEST(2, correct, order);

// Construct an attribute list containing all the ids in this order
order =

    
        Big Screen Television
        1299.99
    
    
        DVD Player
        399.99
    
    
        CD Player
        199.99
    
    
        8-Track Player
        69.99
    
;

order.@allids = order.item.@id;   
TEST_XML(3, "1 2 3 4", order.@allids);

// Replace first child of the order element with an XML value
order =

    
        John
        
948 Ranier Ave.
Portland OR
Big Screen Television 1299.99 DVD Player 399.99 CD Player 199.99 8-Track Player 69.99
; order.*[0] = Fred
123 Foobar Ave.
Bellevue WA
; correct = Fred
123 Foobar Ave.
Bellevue WA
Big Screen Television 1299.99 DVD Player 399.99 CD Player 199.99 8-Track Player 69.99
; TEST(4, correct, order); // Replace the second child of the order element with a list of items order = John
948 Ranier Ave.
Portland OR
Big Screen Television 1299.99 DVD Player 399.99 CD Player 199.99 8-Track Player 69.99
; correct = John
948 Ranier Ave.
Portland OR
item one item two item three DVD Player 399.99 CD Player 199.99 8-Track Player 69.99
; order.item[0] = item one + item two + item three; TEST(5, correct, order); // Replace the third child of the order with a text node order = John
948 Ranier Ave.
Portland OR
Big Screen Television 1299.99 DVD Player 399.99 CD Player 199.99 8-Track Player 69.99
; correct = John
948 Ranier Ave.
Portland OR
Big Screen Television 1299.99 A Text Node CD Player 199.99 8-Track Player 69.99
; order.item[1] = "A Text Node"; TEST(6, correct, order); // append a new item to the end of the order order = John
948 Ranier Ave.
Portland OR
Big Screen Television 1299.99 DVD Player 399.99 CD Player 199.99 8-Track Player 69.99
; correct = John
948 Ranier Ave.
Portland OR
Big Screen Television 1299.99 DVD Player 399.99 CD Player 199.99 8-Track Player 69.99 new item
; order.*[order.*.length()] = new item; TEST(7, correct, order); // Change the price of the item item = Big Screen Television 1299.99 correct = Big Screen Television 99.95 item.price = 99.95; TEST(8, item, correct); // Change the description of the item item = Big Screen Television 1299.99 correct = Mobile Phone 1299.99 item.description = "Mobile Phone"; TEST(9, item, correct); END();




© 2015 - 2024 Weber Informatics LLC | Privacy Policy