19682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall// Copyright 2013 the V8 project authors. All rights reserved. 29682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 39682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall// 49682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall// Redistribution and use in source and binary forms, with or without 59682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall// modification, are permitted provided that the following conditions 69682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall// are met: 79682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall// 1. Redistributions of source code must retain the above copyright 89682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall// notice, this list of conditions and the following disclaimer. 99682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall// 2. Redistributions in binary form must reproduce the above copyright 109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall// notice, this list of conditions and the following disclaimer in the 119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall// documentation and/or other materials provided with the distribution. 129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall// 139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY 149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY 179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halldescription( 259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall"This test checks that toString() round-trip on a function that has do..while in JavaScript does not insert extra semicolon." 269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall); 279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallfunction f1() { 299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall do {} while(0); 309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallfunction f2() { 339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall do {} while(0) 349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallfunction f3() { 379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall do {} while(0) ; 389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallfunction f4() { 419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall do {} while(0) /*empty*/ ; 429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallif (typeof uneval == "undefined") 479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall uneval = function(x) { return '(' + x.toString()+ ')'; } 489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halluf1 = uneval(f1); 519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallueuf1 = uneval(eval(uneval(f1))); 529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halluf2 = uneval(f2); 549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallueuf2 = uneval(eval(uneval(f2))); 559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halluf3 = uneval(f3); 579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallueuf3 = uneval(eval(uneval(f3))); 589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halluf4 = uneval(f4); 609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallueuf4 = uneval(eval(uneval(f4))); 619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallshouldBe("ueuf1", "uf1"); 659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallshouldBe("ueuf2", "uf2"); 669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallshouldBe("ueuf3", "uf3"); 679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallshouldBe("ueuf4", "uf4"); 689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall