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 5757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5768 script->Run(); | 5768 script->Run(); |
5769 ExpectBoolean("Object.isExtensible(undetectable)", false); | 5769 ExpectBoolean("Object.isExtensible(undetectable)", false); |
5770 | 5770 |
5771 source = v8_str("undetectable.y = 2000;"); | 5771 source = v8_str("undetectable.y = 2000;"); |
5772 script = v8_compile(source); | 5772 script = v8_compile(source); |
5773 script->Run(); | 5773 script->Run(); |
5774 ExpectBoolean("undetectable.y == undefined", true); | 5774 ExpectBoolean("undetectable.y == undefined", true); |
5775 } | 5775 } |
5776 | 5776 |
5777 | 5777 |
5778 THREADED_TEST(UndetectableString) { | |
5779 LocalContext env; | |
5780 v8::HandleScope scope(env->GetIsolate()); | |
5781 | |
5782 Local<String> obj = String::NewFromUtf8(env->GetIsolate(), "foo", | |
5783 String::kUndetectableString); | |
5784 env->Global()->Set(v8_str("undetectable"), obj); | |
5785 | |
5786 ExpectString("undetectable", "foo"); | |
5787 ExpectString("typeof undetectable", "undefined"); | |
5788 ExpectString("typeof(undetectable)", "undefined"); | |
5789 ExpectBoolean("typeof undetectable == 'undefined'", true); | |
5790 ExpectBoolean("typeof undetectable == 'string'", false); | |
5791 ExpectBoolean("if (undetectable) { true; } else { false; }", false); | |
5792 ExpectBoolean("!undetectable", true); | |
5793 | |
5794 ExpectObject("true&&undetectable", obj); | |
5795 ExpectBoolean("false&&undetectable", false); | |
5796 ExpectBoolean("true||undetectable", true); | |
5797 ExpectObject("false||undetectable", obj); | |
5798 | |
5799 ExpectObject("undetectable&&true", obj); | |
5800 ExpectObject("undetectable&&false", obj); | |
5801 ExpectBoolean("undetectable||true", true); | |
5802 ExpectBoolean("undetectable||false", false); | |
5803 | |
5804 ExpectBoolean("undetectable==null", true); | |
5805 ExpectBoolean("null==undetectable", true); | |
5806 ExpectBoolean("undetectable==undefined", true); | |
5807 ExpectBoolean("undefined==undetectable", true); | |
5808 ExpectBoolean("undetectable==undetectable", true); | |
5809 | |
5810 | |
5811 ExpectBoolean("undetectable===null", false); | |
5812 ExpectBoolean("null===undetectable", false); | |
5813 ExpectBoolean("undetectable===undefined", false); | |
5814 ExpectBoolean("undefined===undetectable", false); | |
5815 ExpectBoolean("undetectable===undetectable", true); | |
5816 } | |
5817 | |
5818 | |
5819 TEST(UndetectableOptimized) { | |
5820 i::FLAG_allow_natives_syntax = true; | |
5821 LocalContext env; | |
5822 v8::HandleScope scope(env->GetIsolate()); | |
5823 | |
5824 Local<String> obj = String::NewFromUtf8(env->GetIsolate(), "foo", | |
5825 String::kUndetectableString); | |
5826 env->Global()->Set(v8_str("undetectable"), obj); | |
5827 env->Global()->Set(v8_str("detectable"), v8_str("bar")); | |
5828 | |
5829 ExpectString( | |
5830 "function testBranch() {" | |
5831 " if (!%_IsUndetectableObject(undetectable)) throw 1;" | |
5832 " if (%_IsUndetectableObject(detectable)) throw 2;" | |
5833 "}\n" | |
5834 "function testBool() {" | |
5835 " var b1 = !%_IsUndetectableObject(undetectable);" | |
5836 " var b2 = %_IsUndetectableObject(detectable);" | |
5837 " if (b1) throw 3;" | |
5838 " if (b2) throw 4;" | |
5839 " return b1 == b2;" | |
5840 "}\n" | |
5841 "%OptimizeFunctionOnNextCall(testBranch);" | |
5842 "%OptimizeFunctionOnNextCall(testBool);" | |
5843 "for (var i = 0; i < 10; i++) {" | |
5844 " testBranch();" | |
5845 " testBool();" | |
5846 "}\n" | |
5847 "\"PASS\"", | |
5848 "PASS"); | |
5849 } | |
5850 | |
5851 | |
5852 // The point of this test is type checking. We run it only so compilers | 5778 // The point of this test is type checking. We run it only so compilers |
5853 // don't complain about an unused function. | 5779 // don't complain about an unused function. |
5854 TEST(PersistentHandles) { | 5780 TEST(PersistentHandles) { |
5855 LocalContext env; | 5781 LocalContext env; |
5856 v8::Isolate* isolate = CcTest::isolate(); | 5782 v8::Isolate* isolate = CcTest::isolate(); |
5857 v8::HandleScope scope(isolate); | 5783 v8::HandleScope scope(isolate); |
5858 Local<String> str = v8_str("foo"); | 5784 Local<String> str = v8_str("foo"); |
5859 v8::Persistent<String> p_str(isolate, str); | 5785 v8::Persistent<String> p_str(isolate, str); |
5860 p_str.Reset(); | 5786 p_str.Reset(); |
5861 Local<Script> scr = v8_compile(""); | 5787 Local<Script> scr = v8_compile(""); |
(...skipping 16119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21981 "bar2.js"); | 21907 "bar2.js"); |
21982 } | 21908 } |
21983 | 21909 |
21984 | 21910 |
21985 TEST(StreamingScriptWithSourceMappingURLInTheMiddle) { | 21911 TEST(StreamingScriptWithSourceMappingURLInTheMiddle) { |
21986 const char* chunks[] = {"function foo() { ret", "urn 13; }\n//#", | 21912 const char* chunks[] = {"function foo() { ret", "urn 13; }\n//#", |
21987 " sourceMappingURL=bar2.js\n", "foo();", NULL}; | 21913 " sourceMappingURL=bar2.js\n", "foo();", NULL}; |
21988 RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8, true, NULL, | 21914 RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8, true, NULL, |
21989 "bar2.js"); | 21915 "bar2.js"); |
21990 } | 21916 } |
OLD | NEW |