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 1931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1942 "}" | 1942 "}" |
1943 "exception"); | 1943 "exception"); |
1944 CHECK_EQ(1, use_counts[v8::Isolate::kRegExpPrototypeStickyGetter]); | 1944 CHECK_EQ(1, use_counts[v8::Isolate::kRegExpPrototypeStickyGetter]); |
1945 CHECK_EQ(0, use_counts[v8::Isolate::kRegExpPrototypeToString]); | 1945 CHECK_EQ(0, use_counts[v8::Isolate::kRegExpPrototypeToString]); |
1946 CHECK(resultStickyError->IsObject()); | 1946 CHECK(resultStickyError->IsObject()); |
1947 | 1947 |
1948 // RegExp.prototype.toString() returns '/(?:)/' as a compatibility fix; | 1948 // RegExp.prototype.toString() returns '/(?:)/' as a compatibility fix; |
1949 // a UseCounter is incremented to track it. | 1949 // a UseCounter is incremented to track it. |
1950 v8::Local<v8::Value> resultToString = | 1950 v8::Local<v8::Value> resultToString = |
1951 CompileRun("RegExp.prototype.toString().length"); | 1951 CompileRun("RegExp.prototype.toString().length"); |
1952 CHECK_EQ(1, use_counts[v8::Isolate::kRegExpPrototypeStickyGetter]); | 1952 CHECK_EQ(2, use_counts[v8::Isolate::kRegExpPrototypeStickyGetter]); |
1953 CHECK_EQ(1, use_counts[v8::Isolate::kRegExpPrototypeToString]); | 1953 CHECK_EQ(1, use_counts[v8::Isolate::kRegExpPrototypeToString]); |
1954 CHECK(resultToString->IsInt32()); | 1954 CHECK(resultToString->IsInt32()); |
1955 CHECK_EQ(6, | 1955 CHECK_EQ(6, |
1956 resultToString->Int32Value(isolate->GetCurrentContext()).FromJust()); | 1956 resultToString->Int32Value(isolate->GetCurrentContext()).FromJust()); |
1957 | 1957 |
1958 // .toString() works on normal RegExps | 1958 // .toString() works on normal RegExps |
1959 v8::Local<v8::Value> resultReToString = CompileRun("/a/.toString().length"); | 1959 v8::Local<v8::Value> resultReToString = CompileRun("/a/.toString().length"); |
1960 CHECK_EQ(1, use_counts[v8::Isolate::kRegExpPrototypeStickyGetter]); | 1960 CHECK_EQ(2, use_counts[v8::Isolate::kRegExpPrototypeStickyGetter]); |
1961 CHECK_EQ(1, use_counts[v8::Isolate::kRegExpPrototypeToString]); | 1961 CHECK_EQ(1, use_counts[v8::Isolate::kRegExpPrototypeToString]); |
1962 CHECK(resultReToString->IsInt32()); | 1962 CHECK(resultReToString->IsInt32()); |
1963 CHECK_EQ( | 1963 CHECK_EQ( |
1964 3, resultReToString->Int32Value(isolate->GetCurrentContext()).FromJust()); | 1964 3, resultReToString->Int32Value(isolate->GetCurrentContext()).FromJust()); |
1965 | 1965 |
1966 // .toString() throws on non-RegExps that aren't RegExp.prototype | 1966 // .toString() throws on non-RegExps that aren't RegExp.prototype |
1967 v8::Local<v8::Value> resultToStringError = CompileRun( | 1967 v8::Local<v8::Value> resultToStringError = CompileRun( |
1968 "var exception;" | 1968 "var exception;" |
1969 "try { RegExp.prototype.toString.call(null) }" | 1969 "try { RegExp.prototype.toString.call(null) }" |
1970 "catch (e) { exception = e; }" | 1970 "catch (e) { exception = e; }" |
1971 "exception"); | 1971 "exception"); |
1972 CHECK_EQ(1, use_counts[v8::Isolate::kRegExpPrototypeStickyGetter]); | 1972 CHECK_EQ(2, use_counts[v8::Isolate::kRegExpPrototypeStickyGetter]); |
1973 CHECK_EQ(1, use_counts[v8::Isolate::kRegExpPrototypeToString]); | 1973 CHECK_EQ(1, use_counts[v8::Isolate::kRegExpPrototypeToString]); |
1974 CHECK(resultToStringError->IsObject()); | 1974 CHECK(resultToStringError->IsObject()); |
1975 } | 1975 } |
OLD | NEW |