language-ecmascript-0.16.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 LabelSubst = Map (Id ()) (Id ()) Source

class Fixable a where Source

A class of AST elements that need fixup after generation

Methods

fixUp :: a -> Gen a Source

Instances

Data a => Fixable (Statement a) 
Data a => Fixable (ForInInit a) 
Data a => Fixable (ForInit a) 
Data a => Fixable (VarDecl a) 
Data a => Fixable (CatchClause a) 
Data a => Fixable (CaseClause a) 
Data a => Fixable (Expression a) 
Data a => Fixable (LValue a) 
Data a => Fixable (Prop a) 
Fixable (Id a) 
Data a => Fixable (JavaScript a) 

identifierNameFixup :: String -> String Source

Renames empty identifiers, as well as identifiers that are keywords or future reserved words by prepending a '_' to them. Also substitutes illegal characters with a "_" as well.

fixBreakContinue :: Data a => [Statement a] -> Gen [Statement a] Source

Fixes an incorrect nesting of break/continue, making the program abide by the ECMAScript 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). This is done by either assigning a label (from the set of labels in current scope) to a break/continue statement that doesn't have one (or has a label that's not present in the current scope). Additionally, it removes nested labelled statements with duplicate labels (also a requirement imposed by the spec).

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

choose n elements from a list randomly

selectRandomElement :: [a] -> Gen a Source

Selects a random element of the list