OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1933 "\t%s\n" | 1933 "\t%s\n" |
1934 "to contain %d functions, however, received %d functions.\n", | 1934 "to contain %d functions, however, received %d functions.\n", |
1935 program, test_cases[i].functions, | 1935 program, test_cases[i].functions, |
1936 log.function_position() / kDataPerFunction); | 1936 log.function_position() / kDataPerFunction); |
1937 CHECK(false); | 1937 CHECK(false); |
1938 } | 1938 } |
1939 i::ScriptDataImpl data(log.ExtractData()); | 1939 i::ScriptDataImpl data(log.ExtractData()); |
1940 CHECK(!data.has_error()); | 1940 CHECK(!data.has_error()); |
1941 } | 1941 } |
1942 } | 1942 } |
| 1943 |
| 1944 |
| 1945 TEST(FunctionDeclaresItselfStrict) { |
| 1946 // Tests that we produce the right kinds of errors when a function declares |
| 1947 // itself strict (we cannot produce there errors as soon as we see the |
| 1948 // offending identifiers, because we don't know at that point whether the |
| 1949 // function is strict or not). |
| 1950 const char* context_data[][2] = { |
| 1951 {"function eval() {", "}"}, |
| 1952 {"function arguments() {", "}"}, |
| 1953 {"function yield() {", "}"}, |
| 1954 {"function interface() {", "}"}, |
| 1955 {"function foo(eval) {", "}"}, |
| 1956 {"function foo(arguments) {", "}"}, |
| 1957 {"function foo(yield) {", "}"}, |
| 1958 {"function foo(interface) {", "}"}, |
| 1959 {"function foo(bar, eval) {", "}"}, |
| 1960 {"function foo(bar, arguments) {", "}"}, |
| 1961 {"function foo(bar, yield) {", "}"}, |
| 1962 {"function foo(bar, interface) {", "}"}, |
| 1963 {"function foo(bar, bar) {", "}"}, |
| 1964 { NULL, NULL } |
| 1965 }; |
| 1966 |
| 1967 const char* strict_statement_data[] = { |
| 1968 "\"use strict\";", |
| 1969 NULL |
| 1970 }; |
| 1971 |
| 1972 const char* non_strict_statement_data[] = { |
| 1973 ";", |
| 1974 NULL |
| 1975 }; |
| 1976 |
| 1977 RunParserSyncTest(context_data, strict_statement_data, kError); |
| 1978 RunParserSyncTest(context_data, non_strict_statement_data, kSuccess); |
| 1979 } |
OLD | NEW |