language-ecmascript-0.15.2: JavaScript parser and pretty-printer library

Safe HaskellNone
LanguageHaskell2010

Language.ECMAScript3.Syntax.Arbitrary

Description

QuickCheck $Arbitrary$ instances for ECMAScript 3 abstract syntax.

Synopsis

Documentation

cshrink :: Arbitrary a => [a] -> [a] Source

type MSGen a = (Int, Gen a) Source

sGen :: [MSGen a] -> Gen a Source

listOfN :: Arbitrary a => Int -> Gen a -> Gen [a] Source

type LabelSubst = Map (Id ()) (Id ()) Source

fixLabels :: Data a => JavaScript a -> Gen (JavaScript a) Source

Fixes labels so that labeled breaks and continues refer to existing labeled statements, enclosing them; also, reduces the size of the label set. Assumes that the program has a proper syntactic structure, i.e. isProgramFixable s = True.

rChooseElem :: [a] -> Int -> Gen [a] Source

choose n elements from a list randomly

isProgramFixable :: Data a => JavaScript a -> Bool Source

A predicate that tells us whether a program has a fixable/correct label-break/continue structure. The predicate imposes syntactic restrictions on the break, continue and labeled statements as in the ECMA spec

isBreakContinueFixable :: Data a => Statement a -> Bool -> Bool -> Bool -> Bool Source

Imposes relaxed restrictions on break and continue per ECMAScript 5 spec (page 92): any continue without a label should be nested within an iteration stmt, any continue with a label should be nested in a labeled statement (not necessarily with the same label); any break statement without a label should be nested in an iteration or switch stmt, any break statement with a label should be nested in a labeled statement (not necessarily with the same label).

removeDuplicateLabels :: Data a => JavaScript a -> Gen (JavaScript a) Source

Removes duplicate labels from nested labeled statements in order to impose restrictions on labeled statements as per ECMAScript 5 spec (page 95): nested labeled statements cannot have duplicating labels.

selectRandomElement :: [a] -> Gen a Source

Selects a random element of the list

fixBreakContinueLabels :: Data a => JavaScript a -> Gen (JavaScript a) Source

Changes labels of break/continue so that they refer to one of the enclosing labels