From f97fc5cdc56724e98d1f6747fe19a2239167c4cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20K=C3=BChne?= Date: Mon, 9 Jun 2003 07:08:32 +0000 Subject: [PATCH] input file for AnonInnerLength unit tests --- .../checkstyle/InputAnonInnerLength.java | 123 ++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 src/testinputs/com/puppycrawl/tools/checkstyle/InputAnonInnerLength.java diff --git a/src/testinputs/com/puppycrawl/tools/checkstyle/InputAnonInnerLength.java b/src/testinputs/com/puppycrawl/tools/checkstyle/InputAnonInnerLength.java new file mode 100644 index 000000000..301ab4006 --- /dev/null +++ b/src/testinputs/com/puppycrawl/tools/checkstyle/InputAnonInnerLength.java @@ -0,0 +1,123 @@ +//////////////////////////////////////////////////////////////////////////////// +// Test case file for checkstyle. +// Created: 2002 +//////////////////////////////////////////////////////////////////////////////// +package com.puppycrawl.tools.checkstyle; + +import java.awt.event.MouseEvent; +import java.awt.event.MouseAdapter; +import javax.swing.JButton; + +/** + * Tests for length of anonymous inner types + * @author Rob Worth + * @author Lars Kühne + **/ +public class InputAnonInnerLength +{ + /** + * Check that instantiations of normal classes work OK. + */ + private JButton mButton = new JButton(); + + private class MyInner + { + private MyInner(int[] anArray) + { + } + } + + /** + * the AnonInnerLengthCheck works with 'new' and RCURLY - check that + * it will not confuse constructors calls with array params with + * anon inners. + */ + private MyInner myInner = new MyInner(new int[]{ + // make the array span multiple lines + 1, + 2, + 3, + 4, + 5, + 6, + 7, + } + ); + + /** + anon inner in member variable initialization which is 21 lines long + */ + private Runnable mRunnable1 = new Runnable() { + public void run() // should not have to be documented, class is anon. + { + System.out.println("running"); + System.out.println("running"); + System.out.println("running"); + System.out.println("running"); + System.out.println("running"); + System.out.println("running"); + System.out.println("running"); + System.out.println("running"); + System.out.println("running"); + System.out.println("running"); + System.out.println("running"); + System.out.println("running"); + System.out.println("running"); + System.out.println("running"); + System.out.println("running"); + System.out.println("running"); + } + }; + + /** + anon inner in member variable initialization which is 20 lines long + */ + private Runnable mRunnable2 = new Runnable() { + public void run() // should not have to be documented, class is anon. + { + System.out.println("running"); + System.out.println("running"); + System.out.println("running"); + System.out.println("running"); + System.out.println("running"); + System.out.println("running"); + System.out.println("running"); + System.out.println("running"); + System.out.println("running"); + System.out.println("running"); + System.out.println("running"); + System.out.println("running"); + System.out.println("running"); + System.out.println("running"); + System.out.println("running"); + } + }; + + /** + anon inner in constructor. + */ + InputAnonInnerLength() + { + mButton.addMouseListener( new MouseAdapter() + { + public void mouseClicked( MouseEvent aEv ) + { + System.out.println("click"); + } + } ); + } + + /** + anon inner in method + */ + public void addInputAnonInner() + { + mButton.addMouseListener( new MouseAdapter() + { + public void mouseClicked( MouseEvent aEv ) + { + System.out.println("click"); + } + } ); + } +}