jaroslav@1453: /** jaroslav@1453: * Back 2 Browser Bytecode Translator jaroslav@1453: * Copyright (C) 2012 Jaroslav Tulach jaroslav@1453: * jaroslav@1453: * This program is free software: you can redistribute it and/or modify jaroslav@1453: * it under the terms of the GNU General Public License as published by jaroslav@1453: * the Free Software Foundation, version 2 of the License. jaroslav@1453: * jaroslav@1453: * This program is distributed in the hope that it will be useful, jaroslav@1453: * but WITHOUT ANY WARRANTY; without even the implied warranty of jaroslav@1453: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the jaroslav@1453: * GNU General Public License for more details. jaroslav@1453: * jaroslav@1453: * You should have received a copy of the GNU General Public License jaroslav@1453: * along with this program. Look for COPYING file in the top folder. jaroslav@1453: * If not, see http://opensource.org/licenses/GPL-2.0. jaroslav@1453: */ jaroslav@1453: /* jaroslav@1453: * To change this license header, choose License Headers in Project Properties. jaroslav@1453: * To change this template file, choose Tools | Templates jaroslav@1453: * and open the template in the editor. jaroslav@1453: */ jaroslav@1453: jaroslav@1453: package org.apidesign.vm4brwsr; jaroslav@1453: jaroslav@1453: import static org.testng.Assert.assertEquals; jaroslav@1453: import static org.testng.Assert.assertTrue; jaroslav@1453: import org.testng.annotations.AfterClass; jaroslav@1453: import org.testng.annotations.BeforeClass; jaroslav@1453: import org.testng.annotations.Test; jaroslav@1453: jaroslav@1453: /** jaroslav@1453: * jaroslav@1453: * @author Jaroslav Tulach jaroslav@1453: */ jaroslav@1453: public class SizeOfAMethodTest { jaroslav@1453: private static TestVM code; jaroslav@1453: jaroslav@1453: @Test public void sumXYShouldBeSmall() { jaroslav@1453: String s = code.codeSeq().toString(); jaroslav@1453: int beg = s.indexOf("c.sum__III"); jaroslav@1453: int end = s.indexOf("c.sum__III.access"); jaroslav@1453: jaroslav@1453: assertTrue(beg > 0, "Found sum method in " + code.toString()); jaroslav@1453: assertTrue(beg < end, "Found end of sum method in " + code.toString()); jaroslav@1453: jaroslav@1453: String method = s.substring(beg, end); jaroslav@1453: jaroslav@1453: assertEquals(method.indexOf("st"), -1, "There should be no stack operations:\n" + method); jaroslav@1453: } jaroslav@1453: jaroslav@1453: jaroslav@1453: @BeforeClass jaroslav@1453: public static void compileTheCode() throws Exception { jaroslav@1453: StringBuilder sb = new StringBuilder(); jaroslav@1453: code = TestVM.compileClass(sb, "org/apidesign/vm4brwsr/StaticMethod"); jaroslav@1453: } jaroslav@1453: @AfterClass jaroslav@1453: public static void releaseTheCode() { jaroslav@1453: code = null; jaroslav@1453: } jaroslav@1453: jaroslav@1453: }