packages feed

jvm-binary-0.2.0: test/Language/JVM/Attribute/InnerClassesTest.hs

{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE OverloadedStrings #-}

module Language.JVM.Attribute.InnerClassesTest where

import           SpecHelper
import qualified Data.Set as S

import           Language.JVM.ConstantTest               ()

import           Language.JVM.Attribute.InnerClasses
import           Language.JVM

prop_roundtrip_InnerClassesTest :: InnerClasses High -> Property
prop_roundtrip_InnerClassesTest = isoRoundtrip

spec_inner_classes ::  SpecWith ()
spec_inner_classes = do
  it "can find the inner classes of 'Streams$5'" $ do
    tc <- withTestClass "Streams$5"
    cInnerClasses tc `shouldBe`
      [
          InnerClass {
              icClassName = "java/util/PrimitiveIterator$OfDouble",
              icOuterClassName = Just "java/util/PrimitiveIterator",
              icInnerName = Just "OfDouble",
              icInnerAccessFlags = BitSet $ S.fromList [ICPublic, ICStatic, ICInterface, ICAbstract]
          },
          InnerClass {
              icClassName = "com/google/common/collect/Streams$DoubleFunctionWithIndex",
              icOuterClassName = Just "com/google/common/collect/Streams",
              icInnerName = Just "DoubleFunctionWithIndex",
              icInnerAccessFlags = BitSet $ S.fromList [ICPublic, ICStatic, ICInterface, ICAbstract]
          },
          InnerClass {
              icClassName = "com/google/common/collect/Streams$5",
              icOuterClassName = Nothing,
              icInnerName = Nothing,
              icInnerAccessFlags = BitSet $ S.fromList [ ICStatic ]
          },
          InnerClass {
              icClassName = "java/util/Spliterators$AbstractSpliterator",
              icOuterClassName = Just "java/util/Spliterators",
              icInnerName = Just "AbstractSpliterator",
              icInnerAccessFlags = BitSet $ S.fromList [ICPublic, ICStatic, ICAbstract]
          }
      ]

-- test_real_signatures :: SpecWith ()
-- test_real_signatures = do
--   it "can handle Iterator" $ do
--    let signature = "<T:Ljava/lang/Object;>Ljava/lang/Object;"

instance Arbitrary (InnerClasses High) where
  arbitrary = genericArbitraryU

instance Arbitrary (InnerClass High) where
  arbitrary = genericArbitraryU


  -- "Lcom/apple/eawt/_AppEventHandler$_AppEventDispatcher<Lcom/apple/eawt/QuitHandler;>;"
-- "Lcom/apple/eawt/_AppEventHandler$_BooleanAppEventMultiplexor<Lcom/apple/eawt/ScreenSleepListener;Lcom/apple/eawt/AppEvent$ScreenSleepEvent;>;"
-- "Lcom/apple/eawt/_AppEventHandler$_BooleanAppEventMultiplexor<Lcom/apple/eawt/SystemSleepListener;Lcom/apple/eawt/AppEvent$SystemSleepEvent;>;"
-- "Lcom/apple/eawt/_AppEventHandler$_BooleanAppEventMultiplexor<Lcom/apple/eawt/UserSessionListener;Lcom/apple/eawt/AppEvent$UserSessionEvent;>;"