Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
bf502cb
Reifying primitive operations
flbulgarelli Apr 12, 2019
16b4893
Using otherwise reification
flbulgarelli Apr 18, 2019
5f434fd
Renaming PrimitiveOperator
flbulgarelli Apr 18, 2019
d050984
Introducing new inspection
flbulgarelli Apr 18, 2019
24f9e34
Adding corrector draft
flbulgarelli Apr 19, 2019
d60b0b3
Converting tables intro true maps
flbulgarelli Apr 19, 2019
151e088
Introducing default tokens table
flbulgarelli Apr 19, 2019
57829bb
Introducing keyword tables
flbulgarelli Apr 19, 2019
95cb274
Introducing declaresPrimitive and usesPrimitive
flbulgarelli Apr 19, 2019
1508057
Implementing unparsing for operators
flbulgarelli Apr 19, 2019
7632355
Introducing operators module
flbulgarelli Apr 19, 2019
51461a6
Synthesizing primitive inspections
flbulgarelli Apr 19, 2019
7849e7c
Parsing and unparsing generics in Java
flbulgarelli Apr 19, 2019
07b3823
Properly handling and & or in Java
flbulgarelli Apr 20, 2019
91d0deb
Renaming to just Operator
flbulgarelli Apr 20, 2019
d038ffe
Moving Synthesizer to Analyzer module
flbulgarelli Apr 20, 2019
12608c5
Using operators in parsers and unparsers
flbulgarelli Apr 21, 2019
613b0c0
Parameterizing language
flbulgarelli Apr 29, 2019
fd3b562
Introducing Autocorrector module
flbulgarelli May 1, 2019
403cc11
Using language from autocorrector
flbulgarelli May 1, 2019
717c408
Wiring corrector into analyser
flbulgarelli May 1, 2019
31c95e1
Remove inference logic from ExpectationsCompiler
flbulgarelli May 1, 2019
12a26cb
Refactor to autocorrector
flbulgarelli May 1, 2019
982c76e
Adding operator inference capabilities
flbulgarelli May 1, 2019
b816233
Moving synthesize function ideas to Autocorrector
flbulgarelli May 2, 2019
b7b94f1
Removing duplicated logic
flbulgarelli May 2, 2019
0f8ccb8
Removing warnings
flbulgarelli May 2, 2019
2f1f0ee
Adding python unparser
flbulgarelli Apr 12, 2019
cefb669
Java simplest unparsing
flbulgarelli Nov 25, 2017
38ece68
Parsing extends
flbulgarelli Nov 25, 2017
7053461
Splitting unparser into modules
flbulgarelli Nov 25, 2017
ca7e4d4
Parsing simple methods
flbulgarelli Nov 25, 2017
79d1aea
Reusing Unparser definition
flbulgarelli Nov 25, 2017
7c66234
Fixing mulang ast changes
flbulgarelli Apr 14, 2019
a47bbad
Using Unparser module
flbulgarelli Apr 14, 2019
9574573
Reifying primitive operations
flbulgarelli Apr 18, 2019
eb08aed
Adding ruby unparser draft
flbulgarelli Apr 18, 2019
f1bf33e
Unparsing methods, lambdas and prints
flbulgarelli Apr 19, 2019
ded0680
Adding bool tests & making test code more compact
flbulgarelli Apr 19, 2019
68f393b
Introducing unbuilder and grouping bionops
flbulgarelli Apr 19, 2019
a9ed9f7
Extracting number formatting
flbulgarelli Apr 19, 2019
b1d36d7
Implementing unparsing for operators
flbulgarelli Apr 19, 2019
b80e6b9
Extending Java unparser
flbulgarelli Apr 19, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion mulang.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ library
Language.Mulang.Ast
Language.Mulang.Identifier
Language.Mulang.Builder
Language.Mulang.Unbuilder
Language.Mulang.Generator
Language.Mulang.Signature
Language.Mulang.DomainLanguage
Expand All @@ -58,13 +59,23 @@ library
Language.Mulang.Inspector.Typed
Language.Mulang.Parsers
Language.Mulang.Parsers.Haskell
Language.Mulang.Parsers.Prolog
Language.Mulang.Parsers.Java
Language.Mulang.Parsers.JavaScript
Language.Mulang.Parsers.Prolog
Language.Mulang.Parsers.Python
Language.Mulang.Operators
Language.Mulang.Operators.Haskell
Language.Mulang.Operators.Java
Language.Mulang.Operators.Python
Language.Mulang.Operators.Ruby
Language.Mulang.Unparsers
Language.Mulang.Unparsers.Java
Language.Mulang.Unparsers.Python
Language.Mulang.Unparsers.Ruby
Language.Mulang.Analyzer
Language.Mulang.Analyzer.Analysis
Language.Mulang.Analyzer.Analysis.Json
Language.Mulang.Analyzer.Autocorrector
Language.Mulang.Analyzer.DomainLanguageCompiler
Language.Mulang.Analyzer.ExpectationsAnalyzer
Language.Mulang.Analyzer.ExpectationsCompiler
Expand All @@ -73,6 +84,7 @@ library
Language.Mulang.Analyzer.SignatureStyleCompiler
Language.Mulang.Analyzer.SmellsAnalyzer
Language.Mulang.Analyzer.TestsAnalyzer
Language.Mulang.Analyzer.Synthesizer
Language.Mulang.Interpreter
Language.Mulang.Interpreter.Runner

Expand Down
136 changes: 136 additions & 0 deletions spec/AutocorrectorSpec.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
module AutocorrectorSpec (spec) where

import Test.Hspec
import Language.Mulang.Analyzer.Autocorrector
import Language.Mulang.Analyzer.Analysis hiding (spec)
import qualified Language.Mulang.Analyzer.Analysis as A
import Data.Maybe (fromJust)

run language = head . fromJust . expectations . A.spec . autocorrect . expectationsAnalysis (CodeSample language "foo") . (:[])

spec :: Spec
spec = do
describe "correct primitive usages" $ do
it "corrects haskell otherwise negated" $ do
run Haskell (Expectation "*" "Not:Uses:otherwise") `shouldBe` (Expectation "*" "Not:UsesOtherwise")

it "corrects haskell otherwise" $ do
run Haskell (Expectation "*" "Uses:otherwise") `shouldBe` (Expectation "*" "UsesOtherwise")

it "corrects haskell and" $ do
run Haskell (Expectation "*" "Uses:and") `shouldBe` (Expectation "*" "Uses:and")
run Haskell (Expectation "*" "Uses:&&") `shouldBe` (Expectation "*" "UsesAnd")

it "corrects haskell or" $ do
run Haskell (Expectation "*" "Uses:or") `shouldBe` (Expectation "*" "Uses:or")
run Haskell (Expectation "*" "Uses:||")`shouldBe` (Expectation "*" "UsesOr")

it "corrects haskell not" $ do
run Haskell (Expectation "*" "Uses:not") `shouldBe` (Expectation "*" "UsesNegation")
run Haskell (Expectation "*" "Uses:!") `shouldBe` (Expectation "*" "Uses:!")

it "corrects java and" $ do
run Java (Expectation "*" "Uses:and") `shouldBe` (Expectation "*" "Uses:and")
run Java (Expectation "*" "Uses:&&") `shouldBe` (Expectation "*" "UsesAnd")

it "corrects python and" $ do
run Python (Expectation "*" "Uses:and") `shouldBe` (Expectation "*" "UsesAnd")
run Python (Expectation "*" "Uses:&&") `shouldBe` (Expectation "*" "Uses:&&")

it "corrects ruby and" $ do
run Ruby (Expectation "*" "Uses:and") `shouldBe` (Expectation "*" "UsesAnd")
run Ruby (Expectation "*" "Uses:&&") `shouldBe` (Expectation "*" "UsesAnd")

describe "correct primitive declarations" $ do
it "corrects haskell otherwise negated" $ do
run Haskell (Expectation "*" "Not:Declares:otherwise") `shouldBe` (Expectation "*" "Not:DeclaresOtherwise")

it "corrects haskell otherwise" $ do
run Haskell (Expectation "*" "Declares:otherwise") `shouldBe` (Expectation "*" "DeclaresOtherwise")

it "corrects haskell and" $ do
run Haskell (Expectation "*" "Declares:and") `shouldBe` (Expectation "*" "Declares:and")
run Haskell (Expectation "*" "Declares:&&") `shouldBe` (Expectation "*" "DeclaresAnd")

it "corrects haskell or" $ do
run Haskell (Expectation "*" "Declares:or") `shouldBe` (Expectation "*" "Declares:or")
run Haskell (Expectation "*" "Declares:||")`shouldBe` (Expectation "*" "DeclaresOr")

it "corrects haskell not" $ do
run Haskell (Expectation "*" "Declares:not") `shouldBe` (Expectation "*" "DeclaresNegation")
run Haskell (Expectation "*" "Declares:!") `shouldBe` (Expectation "*" "Declares:!")

it "corrects java and" $ do
run Java (Expectation "*" "Declares:and") `shouldBe` (Expectation "*" "Declares:and")
run Java (Expectation "*" "Declares:&&") `shouldBe` (Expectation "*" "DeclaresAnd")

it "corrects python and" $ do
run Python (Expectation "*" "Declares:and") `shouldBe` (Expectation "*" "DeclaresAnd")
run Python (Expectation "*" "Declares:&&") `shouldBe` (Expectation "*" "Declares:&&")

it "corrects ruby and" $ do
run Ruby (Expectation "*" "Declares:and") `shouldBe` (Expectation "*" "DeclaresAnd")
run Ruby (Expectation "*" "Declares:&&") `shouldBe` (Expectation "*" "DeclaresAnd")

describe "corrects keyword usages" $ do
it "corrects haskell type usage with negation" $ do
run Haskell (Expectation "*" "Not:Uses:type") `shouldBe` (Expectation "*" "Not:DeclaresTypeAlias")

it "corrects haskell type usage" $ do
run Haskell (Expectation "*" "Uses:type") `shouldBe` (Expectation "*" "DeclaresTypeAlias")

it "corrects java if usage" $ do
run Java (Expectation "*" "Uses:if") `shouldBe` (Expectation "*" "UsesIf")

it "corrects java class usage" $ do
run Java (Expectation "*" "Uses:class") `shouldBe` (Expectation "*" "DeclaresClass")

it "corrects java interface usage" $ do
run Java (Expectation "*" "Uses:interface") `shouldBe` (Expectation "*" "DeclaresInterface")

it "corrects java for usage" $ do
run Java (Expectation "*" "Uses:for") `shouldBe` (Expectation "*" "UsesForLoop")

it "corrects python def usage" $ do
run Python (Expectation "*" "Uses:def") `shouldBe` (Expectation "*" "DeclaresComputation")

it "corrects ruby class usage" $ do
run Ruby (Expectation "*" "Uses:class") `shouldBe` (Expectation "*" "DeclaresClass")

it "corrects ruby include usage" $ do
run Ruby (Expectation "*" "Uses:include") `shouldBe` (Expectation "*" "Includes")

it "corrects ruby def usage" $ do
run Ruby (Expectation "*" "Uses:def") `shouldBe` (Expectation "*" "DeclaresComputation")


describe "corrects keyword declarations" $ do
it "corrects haskell type declaration with negation" $ do
run Haskell (Expectation "*" "Not:Declares:type") `shouldBe` (Expectation "*" "Not:DeclaresTypeAlias")

it "corrects haskell type declaration" $ do
run Haskell (Expectation "*" "Declares:type") `shouldBe` (Expectation "*" "DeclaresTypeAlias")

it "corrects java if declaration" $ do
run Java (Expectation "*" "Declares:if") `shouldBe` (Expectation "*" "UsesIf")

it "corrects java class declaration" $ do
run Java (Expectation "*" "Declares:class") `shouldBe` (Expectation "*" "DeclaresClass")

it "corrects java interface declaration" $ do
run Java (Expectation "*" "Declares:interface") `shouldBe` (Expectation "*" "DeclaresInterface")

it "corrects java for declaration" $ do
run Java (Expectation "*" "Declares:for") `shouldBe` (Expectation "*" "UsesForLoop")

it "corrects python def declaration" $ do
run Python (Expectation "*" "Declares:def") `shouldBe` (Expectation "*" "DeclaresComputation")

it "corrects ruby class declaration" $ do
run Ruby (Expectation "*" "Declares:class") `shouldBe` (Expectation "*" "DeclaresClass")

it "corrects ruby include declaration" $ do
run Ruby (Expectation "*" "Declares:include") `shouldBe` (Expectation "*" "Includes")

it "corrects ruby def declaration" $ do
run Ruby (Expectation "*" "Declares:def") `shouldBe` (Expectation "*" "DeclaresComputation")
Loading