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 1893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1904 void MockUseCounterCallback(v8::Isolate* isolate, | 1904 void MockUseCounterCallback(v8::Isolate* isolate, |
1905 v8::Isolate::UseCounterFeature feature) { | 1905 v8::Isolate::UseCounterFeature feature) { |
1906 ++global_use_counts[feature]; | 1906 ++global_use_counts[feature]; |
1907 } | 1907 } |
1908 } | 1908 } |
1909 | 1909 |
1910 | 1910 |
1911 // Test that ES2015 RegExp compatibility fixes are in place, that they | 1911 // Test that ES2015 RegExp compatibility fixes are in place, that they |
1912 // are not overly broad, and the appropriate UseCounters are incremented | 1912 // are not overly broad, and the appropriate UseCounters are incremented |
1913 TEST(UseCountRegExp) { | 1913 TEST(UseCountRegExp) { |
1914 i::FLAG_harmony_regexps = true; | |
1915 v8::Isolate* isolate = CcTest::isolate(); | 1914 v8::Isolate* isolate = CcTest::isolate(); |
1916 v8::HandleScope scope(isolate); | 1915 v8::HandleScope scope(isolate); |
1917 LocalContext env; | 1916 LocalContext env; |
1918 int use_counts[v8::Isolate::kUseCounterFeatureCount] = {}; | 1917 int use_counts[v8::Isolate::kUseCounterFeatureCount] = {}; |
1919 global_use_counts = use_counts; | 1918 global_use_counts = use_counts; |
1920 CcTest::isolate()->SetUseCounterCallback(MockUseCounterCallback); | 1919 CcTest::isolate()->SetUseCounterCallback(MockUseCounterCallback); |
1921 | 1920 |
1922 // Compat fix: RegExp.prototype.sticky == undefined; UseCounter tracks it | 1921 // Compat fix: RegExp.prototype.sticky == undefined; UseCounter tracks it |
1923 v8::Local<v8::Value> resultSticky = CompileRun("RegExp.prototype.sticky"); | 1922 v8::Local<v8::Value> resultSticky = CompileRun("RegExp.prototype.sticky"); |
1924 CHECK_EQ(1, use_counts[v8::Isolate::kRegExpPrototypeStickyGetter]); | 1923 CHECK_EQ(1, use_counts[v8::Isolate::kRegExpPrototypeStickyGetter]); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1967 // .toString() throws on non-RegExps that aren't RegExp.prototype | 1966 // .toString() throws on non-RegExps that aren't RegExp.prototype |
1968 v8::Local<v8::Value> resultToStringError = CompileRun( | 1967 v8::Local<v8::Value> resultToStringError = CompileRun( |
1969 "var exception;" | 1968 "var exception;" |
1970 "try { RegExp.prototype.toString.call(null) }" | 1969 "try { RegExp.prototype.toString.call(null) }" |
1971 "catch (e) { exception = e; }" | 1970 "catch (e) { exception = e; }" |
1972 "exception"); | 1971 "exception"); |
1973 CHECK_EQ(1, use_counts[v8::Isolate::kRegExpPrototypeStickyGetter]); | 1972 CHECK_EQ(1, use_counts[v8::Isolate::kRegExpPrototypeStickyGetter]); |
1974 CHECK_EQ(1, use_counts[v8::Isolate::kRegExpPrototypeToString]); | 1973 CHECK_EQ(1, use_counts[v8::Isolate::kRegExpPrototypeToString]); |
1975 CHECK(resultToStringError->IsObject()); | 1974 CHECK(resultToStringError->IsObject()); |
1976 } | 1975 } |
OLD | NEW |