| 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
| 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
| 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
| 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 5 | |
| 6 | gTestfile = 'lexical-027.js'; |
| 7 | |
| 8 | /** |
| 9 | File Name: lexical-027.js |
| 10 | Corresponds To: 7.4.2-4-n.js |
| 11 | ECMA Section: 7.4.2 |
| 12 | |
| 13 | Description: |
| 14 | The following tokens are ECMAScript keywords and may not be used as |
| 15 | identifiers in ECMAScript programs. |
| 16 | |
| 17 | Syntax |
| 18 | |
| 19 | var |
| 20 | |
| 21 | Keyword :: one of |
| 22 | break for new var |
| 23 | continue function return void |
| 24 | delete if this while |
| 25 | else in typeof with |
| 26 | |
| 27 | This test verifies that the keyword cannot be used as an identifier. |
| 28 | Functioinal tests of the keyword may be found in the section corresponding |
| 29 | to the function of the keyword. |
| 30 | |
| 31 | Author: [email protected] |
| 32 | Date: 12 november 1997 |
| 33 | |
| 34 | */ |
| 35 | var SECTION = "lexical-027"; |
| 36 | var VERSION = "JS1_4"; |
| 37 | var TITLE = "Keywords"; |
| 38 | |
| 39 | startTest(); |
| 40 | writeHeaderToLog( SECTION + " "+ TITLE); |
| 41 | |
| 42 | var result = "Failed"; |
| 43 | var exception = "No exception thrown"; |
| 44 | var expect = "Passed"; |
| 45 | |
| 46 | try { |
| 47 | eval("var var;"); |
| 48 | } catch ( e ) { |
| 49 | result = expect; |
| 50 | exception = e.toString(); |
| 51 | } |
| 52 | |
| 53 | new TestCase( |
| 54 | SECTION, |
| 55 | "var var" + |
| 56 | " (threw " + exception +")", |
| 57 | expect, |
| 58 | result ); |
| 59 | |
| 60 | test(); |
| 61 | |
| 62 |