Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Commit ade8e8b

Browse files
committed
Use isJust where applicable
1 parent 915937c commit ade8e8b

File tree

5 files changed

+39
-39
lines changed

5 files changed

+39
-39
lines changed

test/Analysis/Go/Spec.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ spec = parallel $ do
1414
(scopeGraph, (heap, res)) <- evaluate ["main.go", "foo/foo.go", "bar/bar.go", "bar/rab.go"]
1515
case ModuleTable.lookup "main.go" <$> res of
1616
Right (Just (Module _ (scopeAndFrame, _))) -> do
17-
() <$ SpecHelpers.lookupDeclaration "foo" scopeAndFrame heap scopeGraph `shouldBe` Just ()
17+
SpecHelpers.lookupDeclaration "foo" scopeAndFrame heap scopeGraph `shouldSatisfy` isJust
1818
SpecHelpers.lookupMembers "foo" Import scopeAndFrame heap scopeGraph `shouldBe` Just ["New"]
19-
() <$ SpecHelpers.lookupDeclaration "main" scopeAndFrame heap scopeGraph `shouldBe` Just ()
20-
() <$ SpecHelpers.lookupDeclaration "Bar" scopeAndFrame heap scopeGraph `shouldBe` Just ()
21-
() <$ SpecHelpers.lookupDeclaration "Rab" scopeAndFrame heap scopeGraph `shouldBe` Just ()
19+
SpecHelpers.lookupDeclaration "main" scopeAndFrame heap scopeGraph `shouldSatisfy` isJust
20+
SpecHelpers.lookupDeclaration "Bar" scopeAndFrame heap scopeGraph `shouldSatisfy` isJust
21+
SpecHelpers.lookupDeclaration "Rab" scopeAndFrame heap scopeGraph `shouldSatisfy` isJust
2222
other -> expectationFailure (show other)
2323

2424
it "imports with aliases (and side effects only)" $ do
2525
(scopeGraph, (heap, res)) <- evaluate ["main1.go", "foo/foo.go", "bar/bar.go", "bar/rab.go"]
2626
case ModuleTable.lookup "main1.go" <$> res of
2727
Right (Just (Module _ (scopeAndFrame, _))) -> do
28-
() <$ SpecHelpers.lookupDeclaration "f" scopeAndFrame heap scopeGraph `shouldBe` Just ()
29-
() <$ SpecHelpers.lookupDeclaration "main" scopeAndFrame heap scopeGraph `shouldBe` Just ()
28+
SpecHelpers.lookupDeclaration "f" scopeAndFrame heap scopeGraph `shouldSatisfy` isJust
29+
SpecHelpers.lookupDeclaration "main" scopeAndFrame heap scopeGraph `shouldSatisfy` isJust
3030
-- (lookupDeclaration "f" heap >>= deNamespace heap) `shouldBe` Just ("f", ["New"])
3131
other -> expectationFailure (show other)
3232

test/Analysis/PHP/Spec.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,25 @@ spec = parallel $ do
1616
case ModuleTable.lookup "main.php" <$> res of
1717
Right (Just (Module _ (scopeAndFrame, value))) -> do
1818
value `shouldBe` Value.Unit
19-
() <$ SpecHelpers.lookupDeclaration "bar" scopeAndFrame heap scopeGraph `shouldBe` Just ()
20-
() <$ SpecHelpers.lookupDeclaration "foo" scopeAndFrame heap scopeGraph `shouldBe` Just ()
19+
SpecHelpers.lookupDeclaration "bar" scopeAndFrame heap scopeGraph `shouldSatisfy` isJust
20+
SpecHelpers.lookupDeclaration "foo" scopeAndFrame heap scopeGraph `shouldSatisfy` isJust
2121
other -> expectationFailure (show other)
2222

2323
xit "evaluates include_once and require_once" $ do
2424
(scopeGraph, (heap, res)) <- evaluate ["main_once.php", "foo.php", "bar.php"]
2525
case ModuleTable.lookup "main_once.php" <$> res of
2626
Right (Just (Module _ (scopeAndFrame, value))) -> do
2727
value `shouldBe` Value.Unit
28-
() <$ SpecHelpers.lookupDeclaration "bar" scopeAndFrame heap scopeGraph `shouldBe` Just ()
29-
() <$ SpecHelpers.lookupDeclaration "foo" scopeAndFrame heap scopeGraph `shouldBe` Just ()
28+
SpecHelpers.lookupDeclaration "bar" scopeAndFrame heap scopeGraph `shouldSatisfy` isJust
29+
SpecHelpers.lookupDeclaration "foo" scopeAndFrame heap scopeGraph `shouldSatisfy` isJust
3030
other -> expectationFailure (show other)
3131

3232
xit "evaluates namespaces" $ do
3333
(scopeGraph, (heap, res)) <- evaluate ["namespaces.php"]
3434
case ModuleTable.lookup "namespaces.php" <$> res of
3535
Right (Just (Module _ (scopeAndFrame, _))) -> do
36-
() <$ SpecHelpers.lookupDeclaration "Foo" scopeAndFrame heap scopeGraph `shouldBe` Just ()
37-
() <$ SpecHelpers.lookupDeclaration "NS1" scopeAndFrame heap scopeGraph `shouldBe` Just ()
36+
SpecHelpers.lookupDeclaration "Foo" scopeAndFrame heap scopeGraph `shouldSatisfy` isJust
37+
SpecHelpers.lookupDeclaration "NS1" scopeAndFrame heap scopeGraph `shouldSatisfy` isJust
3838

3939
undefined
4040
-- (derefQName heap ("NS1" :| []) env >>= deNamespace heap) `shouldBe` Just ("NS1", ["Sub1", "b", "c"])

test/Analysis/Python/Spec.hs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ spec = parallel $ do
1616
(scopeGraph, (heap, res)) <- evaluate ["main.py", "a.py", "b/__init__.py", "b/c.py"]
1717
case ModuleTable.lookup "main.py" <$> res of
1818
Right (Just (Module _ (scopeAndFrame, _))) -> do
19-
() <$ SpecHelpers.lookupDeclaration "a" scopeAndFrame heap scopeGraph `shouldBe` Just ()
20-
() <$ SpecHelpers.lookupDeclaration "b" scopeAndFrame heap scopeGraph `shouldBe` Just ()
19+
SpecHelpers.lookupDeclaration "a" scopeAndFrame heap scopeGraph `shouldSatisfy` isJust
20+
SpecHelpers.lookupDeclaration "b" scopeAndFrame heap scopeGraph `shouldSatisfy` isJust
2121

2222
fromJust (SpecHelpers.lookupMembers "a" Import scopeAndFrame heap scopeGraph) `shouldContain` [ "foo" ]
2323
fromJust (SpecHelpers.lookupMembers "b" Import scopeAndFrame heap scopeGraph) `shouldContain` ["c"]
@@ -28,16 +28,16 @@ spec = parallel $ do
2828
(scopeGraph, (heap, res)) <- evaluate ["main1.py", "a.py", "b/__init__.py", "b/c.py"]
2929
case ModuleTable.lookup "main1.py" <$> res of
3030
Right (Just (Module _ (scopeAndFrame, _))) -> do
31-
() <$ SpecHelpers.lookupDeclaration "b" scopeAndFrame heap scopeGraph `shouldBe` Just ()
32-
() <$ SpecHelpers.lookupDeclaration "e" scopeAndFrame heap scopeGraph `shouldBe` Just ()
31+
SpecHelpers.lookupDeclaration "b" scopeAndFrame heap scopeGraph `shouldSatisfy` isJust
32+
SpecHelpers.lookupDeclaration "e" scopeAndFrame heap scopeGraph `shouldSatisfy` isJust
3333
other -> expectationFailure (show other)
3434

3535
it "imports using from syntax" $ do
3636
(scopeGraph, (heap, res)) <- evaluate ["main2.py", "a.py", "b/__init__.py", "b/c.py"]
3737
case ModuleTable.lookup "main2.py" <$> res of
3838
Right (Just (Module _ (scopeAndFrame, _))) -> do
39-
() <$ SpecHelpers.lookupDeclaration "bar" scopeAndFrame heap scopeGraph `shouldBe` Just ()
40-
() <$ SpecHelpers.lookupDeclaration "foo" scopeAndFrame heap scopeGraph `shouldBe` Just ()
39+
SpecHelpers.lookupDeclaration "bar" scopeAndFrame heap scopeGraph `shouldSatisfy` isJust
40+
SpecHelpers.lookupDeclaration "foo" scopeAndFrame heap scopeGraph `shouldSatisfy` isJust
4141

4242
-- TODO: Enable when we constrain edge paths with path predicates
4343
-- () <$ SpecHelpers.lookupDeclaration "baz" heap scopeGraph `shouldBe` Nothing
@@ -47,16 +47,16 @@ spec = parallel $ do
4747
(scopeGraph, (heap, res)) <- evaluate ["main3.py", "c/__init__.py", "c/utils.py"]
4848
case ModuleTable.lookup "main3.py" <$> res of
4949
Right (Just (Module _ (scopeAndFrame, _))) -> do
50-
() <$ SpecHelpers.lookupDeclaration "utils" scopeAndFrame heap scopeGraph `shouldBe` Just ()
50+
SpecHelpers.lookupDeclaration "utils" scopeAndFrame heap scopeGraph `shouldSatisfy` isJust
5151
-- (lookupDeclaration "utils" heap >>= deNamespace heap) `shouldBe` Just ("utils", ["to_s"])
5252
other -> expectationFailure (show other)
5353

5454
it "subclasses" $ do
5555
(scopeGraph, (heap, res)) <- evaluate ["subclass.py"]
5656
case ModuleTable.lookup "subclass.py" <$> res of
5757
Right (Just (Module _ (scopeAndFrame, value))) -> do
58-
() <$ SpecHelpers.lookupDeclaration "Foo" scopeAndFrame heap scopeGraph `shouldBe` Just ()
59-
() <$ SpecHelpers.lookupDeclaration "Bar" scopeAndFrame heap scopeGraph `shouldBe` Just ()
58+
SpecHelpers.lookupDeclaration "Foo" scopeAndFrame heap scopeGraph `shouldSatisfy` isJust
59+
SpecHelpers.lookupDeclaration "Bar" scopeAndFrame heap scopeGraph `shouldSatisfy` isJust
6060
SpecHelpers.lookupMembers "Bar" Superclass scopeAndFrame heap scopeGraph `shouldBe` Just [ "dang" ]
6161
value `shouldBe` String "\"bar\""
6262
other -> expectationFailure (show other)

test/Analysis/Ruby/Spec.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ spec = parallel $ do
2222
case ModuleTable.lookup "main.rb" <$> res of
2323
Right (Just (Module _ (scopeAndFrame, value))) -> do
2424
value `shouldBe` Value.Integer (Number.Integer 1)
25-
() <$ SpecHelpers.lookupDeclaration "foo" scopeAndFrame heap scopeGraph `shouldBe` Just ()
25+
SpecHelpers.lookupDeclaration "foo" scopeAndFrame heap scopeGraph `shouldSatisfy` isJust
2626
other -> expectationFailure (show other)
2727

2828
it "evaluates load" $ do
2929
(scopeGraph, (heap, res)) <- evaluate ["load.rb", "foo.rb"]
3030
case ModuleTable.lookup "load.rb" <$> res of
3131
Right (Just (Module _ (scopeAndFrame, value))) -> do
3232
value `shouldBe` Value.Integer (Number.Integer 1)
33-
() <$ SpecHelpers.lookupDeclaration "foo" scopeAndFrame heap scopeGraph `shouldBe` Just ()
33+
SpecHelpers.lookupDeclaration "foo" scopeAndFrame heap scopeGraph `shouldSatisfy` isJust
3434
other -> expectationFailure (show other)
3535

3636
it "evaluates load with wrapper" $ do
@@ -42,16 +42,16 @@ spec = parallel $ do
4242
case ModuleTable.lookup "subclass.rb" <$> res of
4343
Right (Just (Module _ (scopeAndFrame, value))) -> do
4444
value `shouldBe` String "\"<bar>\""
45-
() <$ SpecHelpers.lookupDeclaration "Bar" scopeAndFrame heap scopeGraph `shouldBe` Just ()
46-
() <$ SpecHelpers.lookupDeclaration "Foo" scopeAndFrame heap scopeGraph `shouldBe` Just ()
45+
SpecHelpers.lookupDeclaration "Bar" scopeAndFrame heap scopeGraph `shouldSatisfy` isJust
46+
SpecHelpers.lookupDeclaration "Foo" scopeAndFrame heap scopeGraph `shouldSatisfy` isJust
4747
SpecHelpers.lookupMembers "Bar" Superclass scopeAndFrame heap scopeGraph `shouldBe` Just ["baz", "foo", "inspect"]
4848
other -> expectationFailure (show other)
4949

5050
it "evaluates modules" $ do
5151
(scopeGraph, (heap, res)) <- evaluate ["modules.rb"]
5252
case ModuleTable.lookup "modules.rb" <$> res of
5353
Right (Just (Module _ (scopeAndFrame, _))) -> do
54-
() <$ SpecHelpers.lookupDeclaration "Bar" scopeAndFrame heap scopeGraph `shouldBe` Just ()
54+
SpecHelpers.lookupDeclaration "Bar" scopeAndFrame heap scopeGraph `shouldSatisfy` isJust
5555
other -> expectationFailure (show other)
5656

5757
it "handles break correctly" $ do
@@ -95,7 +95,7 @@ spec = parallel $ do
9595
case ModuleTable.lookup "puts.rb" <$> res of
9696
Right (Just (Module _ (scopeAndFrame, value))) -> do
9797
value `shouldBe` Unit
98-
() <$ SpecHelpers.lookupDeclaration "puts" scopeAndFrame heap scopeGraph `shouldBe` Just ()
98+
SpecHelpers.lookupDeclaration "puts" scopeAndFrame heap scopeGraph `shouldSatisfy` isJust
9999
other -> expectationFailure (show other)
100100

101101
where

test/Analysis/TypeScript/Spec.hs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,53 +29,53 @@ spec = parallel $ do
2929
(scopeGraph, (heap, res)) <- evaluate ["main6.ts", "baz.ts", "foo.ts"]
3030
case ModuleTable.lookup "main6.ts" <$> res of
3131
Right (Just (Module _ (scopeAndFrame, _))) -> do
32-
() <$ SpecHelpers.lookupDeclaration "foo" scopeAndFrame heap scopeGraph `shouldBe` Just ()
32+
SpecHelpers.lookupDeclaration "foo" scopeAndFrame heap scopeGraph `shouldSatisfy` isJust
3333
other -> expectationFailure (show other)
3434

3535
it "imports with aliased symbols" $ do
3636
(scopeGraph, (heap, res)) <- evaluate ["main.ts", "foo.ts", "foo/b.ts"]
3737
case ModuleTable.lookup "main.ts" <$> res of
3838
Right (Just (Module _ (scopeAndFrame, _))) -> do
39-
() <$ SpecHelpers.lookupDeclaration "bar" scopeAndFrame heap scopeGraph `shouldBe` Just ()
40-
() <$ SpecHelpers.lookupDeclaration "quz" scopeAndFrame heap scopeGraph `shouldBe` Just ()
39+
SpecHelpers.lookupDeclaration "bar" scopeAndFrame heap scopeGraph `shouldSatisfy` isJust
40+
SpecHelpers.lookupDeclaration "quz" scopeAndFrame heap scopeGraph `shouldSatisfy` isJust
4141

4242
other -> expectationFailure (show other)
4343

4444
it "imports with qualified names" $ do
4545
(scopeGraph, (heap, res)) <- evaluate ["main1.ts", "foo.ts", "a.ts"]
4646
case ModuleTable.lookup "main1.ts" <$> res of
4747
Right (Just (Module _ (scopeAndFrame, _))) -> do
48-
() <$ SpecHelpers.lookupDeclaration "b" scopeAndFrame heap scopeGraph `shouldBe` Just ()
49-
() <$ SpecHelpers.lookupDeclaration "z" scopeAndFrame heap scopeGraph `shouldBe` Just ()
48+
SpecHelpers.lookupDeclaration "b" scopeAndFrame heap scopeGraph `shouldSatisfy` isJust
49+
SpecHelpers.lookupDeclaration "z" scopeAndFrame heap scopeGraph `shouldSatisfy` isJust
5050

5151
lookupMembers "b" Import scopeAndFrame heap scopeGraph `shouldBe` Just [ "baz", "foo" ]
5252
lookupMembers "z" Import scopeAndFrame heap scopeGraph `shouldBe` Just [ "baz", "foo" ]
5353

54-
() <$ SpecHelpers.lookupDeclaration "baz" scopeAndFrame heap scopeGraph `shouldBe` Nothing
55-
() <$ SpecHelpers.lookupDeclaration "foo" scopeAndFrame heap scopeGraph `shouldBe` Nothing
54+
SpecHelpers.lookupDeclaration "baz" scopeAndFrame heap scopeGraph `shouldBe` Nothing
55+
SpecHelpers.lookupDeclaration "foo" scopeAndFrame heap scopeGraph `shouldBe` Nothing
5656
other -> expectationFailure (show other)
5757

5858
it "stores function declaration in scope graph" $ do
5959
(scopeGraph, (heap, res)) <- evaluate ["a.ts"]
6060
case ModuleTable.lookup "a.ts" <$> res of
6161
Right (Just (Module _ (scopeAndFrame, value))) -> do
62-
() <$ SpecHelpers.lookupDeclaration "baz" scopeAndFrame heap scopeGraph `shouldBe` Just ()
62+
SpecHelpers.lookupDeclaration "baz" scopeAndFrame heap scopeGraph `shouldSatisfy` isJust
6363
value `shouldBe` Unit
6464
other -> expectationFailure (show other)
6565

6666
it "imports functions" $ do
6767
(scopeGraph, (heap, res)) <- evaluate ["main4.ts", "foo.ts"]
6868
case ModuleTable.lookup "main4.ts" <$> res of
6969
Right (Just (Module _ (scopeAndFrame, value))) -> do
70-
() <$ SpecHelpers.lookupDeclaration "foo" scopeAndFrame heap scopeGraph `shouldBe` Just ()
70+
SpecHelpers.lookupDeclaration "foo" scopeAndFrame heap scopeGraph `shouldSatisfy` isJust
7171
value `shouldBe` String (pack "\"this is the foo function\"")
7272
other -> expectationFailure (show other)
7373

7474
it "side effect only imports dont expose exports" $ do
7575
(scopeGraph, (heap, res)) <- evaluate ["main3.ts", "a.ts"]
7676
case ModuleTable.lookup "main3.ts" <$> res of
7777
Right (Just (Module _ (scopeAndFrame, value))) -> do
78-
() <$ SpecHelpers.lookupDeclaration "baz" scopeAndFrame heap scopeGraph `shouldBe` Nothing
78+
SpecHelpers.lookupDeclaration "baz" scopeAndFrame heap scopeGraph `shouldBe` Nothing
7979
value `shouldBe` Unit
8080
Heap.heapSize heap `shouldBe` 4
8181
other -> expectationFailure (show other)
@@ -88,7 +88,7 @@ spec = parallel $ do
8888
(scopeGraph, (heap, res)) <- evaluate ["early-return.ts"]
8989
case ModuleTable.lookup "early-return.ts" <$> res of
9090
Right (Just (Module _ (scopeAndFrame, _))) ->
91-
() <$ SpecHelpers.lookupDeclaration "foo" scopeAndFrame heap scopeGraph `shouldBe` Just ()
91+
SpecHelpers.lookupDeclaration "foo" scopeAndFrame heap scopeGraph `shouldSatisfy` isJust
9292
other -> expectationFailure (show other)
9393

9494
it "evaluates sequence expressions" $ do
@@ -117,7 +117,7 @@ spec = parallel $ do
117117
case ModuleTable.lookup "await.ts" <$> res of
118118
Right (Just (Module _ (scopeAndFrame, _))) -> do
119119
-- Test that f2 is in the scopegraph and heap.
120-
() <$ SpecHelpers.lookupDeclaration "f2" scopeAndFrame heap scopeGraph `shouldBe` Just ()
120+
SpecHelpers.lookupDeclaration "f2" scopeAndFrame heap scopeGraph `shouldSatisfy` isJust
121121
-- Test we can't reference y from outside the function
122122
SpecHelpers.lookupDeclaration "y" scopeAndFrame heap scopeGraph `shouldBe` Nothing
123123
other -> expectationFailure (show other)

0 commit comments

Comments
 (0)