110353ed766fc48a0af6bd33d934439e695c03e3Mahmood Ali/***
210353ed766fc48a0af6bd33d934439e695c03e3Mahmood Ali * ASM tests
310353ed766fc48a0af6bd33d934439e695c03e3Mahmood Ali * Copyright (c) 2002-2005 France Telecom
410353ed766fc48a0af6bd33d934439e695c03e3Mahmood Ali * All rights reserved.
510353ed766fc48a0af6bd33d934439e695c03e3Mahmood Ali *
610353ed766fc48a0af6bd33d934439e695c03e3Mahmood Ali * Redistribution and use in source and binary forms, with or without
710353ed766fc48a0af6bd33d934439e695c03e3Mahmood Ali * modification, are permitted provided that the following conditions
810353ed766fc48a0af6bd33d934439e695c03e3Mahmood Ali * are met:
910353ed766fc48a0af6bd33d934439e695c03e3Mahmood Ali * 1. Redistributions of source code must retain the above copyright
1010353ed766fc48a0af6bd33d934439e695c03e3Mahmood Ali *    notice, this list of conditions and the following disclaimer.
1110353ed766fc48a0af6bd33d934439e695c03e3Mahmood Ali * 2. Redistributions in binary form must reproduce the above copyright
1210353ed766fc48a0af6bd33d934439e695c03e3Mahmood Ali *    notice, this list of conditions and the following disclaimer in the
1310353ed766fc48a0af6bd33d934439e695c03e3Mahmood Ali *    documentation and/or other materials provided with the distribution.
1410353ed766fc48a0af6bd33d934439e695c03e3Mahmood Ali * 3. Neither the name of the copyright holders nor the names of its
1510353ed766fc48a0af6bd33d934439e695c03e3Mahmood Ali *    contributors may be used to endorse or promote products derived from
1610353ed766fc48a0af6bd33d934439e695c03e3Mahmood Ali *    this software without specific prior written permission.
1710353ed766fc48a0af6bd33d934439e695c03e3Mahmood Ali *
1810353ed766fc48a0af6bd33d934439e695c03e3Mahmood Ali * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1910353ed766fc48a0af6bd33d934439e695c03e3Mahmood Ali * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2010353ed766fc48a0af6bd33d934439e695c03e3Mahmood Ali * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2110353ed766fc48a0af6bd33d934439e695c03e3Mahmood Ali * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
2210353ed766fc48a0af6bd33d934439e695c03e3Mahmood Ali * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2310353ed766fc48a0af6bd33d934439e695c03e3Mahmood Ali * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2410353ed766fc48a0af6bd33d934439e695c03e3Mahmood Ali * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2510353ed766fc48a0af6bd33d934439e695c03e3Mahmood Ali * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2610353ed766fc48a0af6bd33d934439e695c03e3Mahmood Ali * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2710353ed766fc48a0af6bd33d934439e695c03e3Mahmood Ali * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
2810353ed766fc48a0af6bd33d934439e695c03e3Mahmood Ali * THE POSSIBILITY OF SUCH DAMAGE.
2910353ed766fc48a0af6bd33d934439e695c03e3Mahmood Ali */
3010353ed766fc48a0af6bd33d934439e695c03e3Mahmood Alipackage org.objectweb.asm.tree.analysis;
3110353ed766fc48a0af6bd33d934439e695c03e3Mahmood Ali
3210353ed766fc48a0af6bd33d934439e695c03e3Mahmood Aliimport java.util.List;
3310353ed766fc48a0af6bd33d934439e695c03e3Mahmood Ali
3410353ed766fc48a0af6bd33d934439e695c03e3Mahmood Aliimport junit.framework.TestSuite;
3510353ed766fc48a0af6bd33d934439e695c03e3Mahmood Ali
3610353ed766fc48a0af6bd33d934439e695c03e3Mahmood Aliimport org.objectweb.asm.AbstractTest;
3710353ed766fc48a0af6bd33d934439e695c03e3Mahmood Aliimport org.objectweb.asm.ClassReader;
3810353ed766fc48a0af6bd33d934439e695c03e3Mahmood Aliimport org.objectweb.asm.tree.ClassNode;
3910353ed766fc48a0af6bd33d934439e695c03e3Mahmood Aliimport org.objectweb.asm.tree.MethodNode;
4010353ed766fc48a0af6bd33d934439e695c03e3Mahmood Ali
4110353ed766fc48a0af6bd33d934439e695c03e3Mahmood Ali/**
4210353ed766fc48a0af6bd33d934439e695c03e3Mahmood Ali * Verifier tests.
4310353ed766fc48a0af6bd33d934439e695c03e3Mahmood Ali *
4410353ed766fc48a0af6bd33d934439e695c03e3Mahmood Ali * @author Eric Bruneton
4510353ed766fc48a0af6bd33d934439e695c03e3Mahmood Ali */
4610353ed766fc48a0af6bd33d934439e695c03e3Mahmood Alipublic class SimpleVerifierTest extends AbstractTest {
4710353ed766fc48a0af6bd33d934439e695c03e3Mahmood Ali
4810353ed766fc48a0af6bd33d934439e695c03e3Mahmood Ali    public static TestSuite suite() throws Exception {
4910353ed766fc48a0af6bd33d934439e695c03e3Mahmood Ali        return new SimpleVerifierTest().getSuite();
5010353ed766fc48a0af6bd33d934439e695c03e3Mahmood Ali    }
5110353ed766fc48a0af6bd33d934439e695c03e3Mahmood Ali
5210353ed766fc48a0af6bd33d934439e695c03e3Mahmood Ali    public void test() throws Exception {
5310353ed766fc48a0af6bd33d934439e695c03e3Mahmood Ali        ClassReader cr = new ClassReader(is);
5410353ed766fc48a0af6bd33d934439e695c03e3Mahmood Ali        ClassNode cn = new ClassNode();
5510353ed766fc48a0af6bd33d934439e695c03e3Mahmood Ali        cr.accept(cn, false);
5610353ed766fc48a0af6bd33d934439e695c03e3Mahmood Ali        List methods = cn.methods;
5710353ed766fc48a0af6bd33d934439e695c03e3Mahmood Ali        for (int i = 0; i < methods.size(); ++i) {
5810353ed766fc48a0af6bd33d934439e695c03e3Mahmood Ali            MethodNode method = (MethodNode) methods.get(i);
5910353ed766fc48a0af6bd33d934439e695c03e3Mahmood Ali            if (method.instructions.size() > 0) {
6010353ed766fc48a0af6bd33d934439e695c03e3Mahmood Ali                Analyzer a = new Analyzer(new SimpleVerifier());
6110353ed766fc48a0af6bd33d934439e695c03e3Mahmood Ali                a.analyze(cn.name, method);
6210353ed766fc48a0af6bd33d934439e695c03e3Mahmood Ali            }
6310353ed766fc48a0af6bd33d934439e695c03e3Mahmood Ali        }
6410353ed766fc48a0af6bd33d934439e695c03e3Mahmood Ali    }
6510353ed766fc48a0af6bd33d934439e695c03e3Mahmood Ali}
66