Skip to content

Commit 9072c95

Browse files
committed
test case
1 parent dee47cc commit 9072c95

34 files changed

+99
-23
lines changed

answers-script.cabal

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,4 +145,8 @@ test-suite answers-script-test
145145
base ^>=4.21.0.0,
146146
answers-script,
147147
filepath,
148-
containers
148+
containers,
149+
directory-tree,
150+
HUnit,
151+
text,
152+
bytestring

test/Main.hs

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,42 @@
11
module Main (main) where
2-
import MyLib qualified
3-
import MyGit qualified
4-
import System.FilePath
2+
53
import Control.Monad
64
import Data.Map
7-
5+
import MyLib qualified
6+
import System.Directory.Tree qualified as DT
7+
import System.FilePath
8+
import Test.HUnit
9+
import qualified System.Directory.Tree as DT
10+
import qualified Data.ByteString as B
11+
import Data.Text qualified as T
12+
import Data.Text.IO qualified as TIO
13+
import Data.Text.Encoding qualified as Encoding
14+
import Control.Exception
15+
import Data.Either qualified as E
816
src :: FilePath
917
src = "test" </> "answers-db"
1018

1119
dst :: FilePath
1220
dst = "test" </> "dst"
1321

22+
expect :: FilePath
23+
expect = "test" </> "expect"
24+
1425
prefix :: String
1526
prefix = "prefix"
1627

1728
main :: IO ()
1829
main = do
19-
pageDatas <- MyLib.someFunc prefix src dst
20-
forM_ pageDatas print
30+
count <- runTestTT testCase
31+
print $ showCounts count
32+
testCase =
33+
TestCase
34+
( do
35+
_ <- MyLib.someFunc prefix src dst
36+
let reader x = do
37+
b <- B.readFile x
38+
return $ E.fromRight (T.pack $ x ++ ": " ++ show (B.length b)) $ Encoding.decodeUtf8' b
39+
a <- DT.readDirectoryWith reader dst
40+
b <- DT.readDirectoryWith reader expect
41+
assertEqual "for the first result of partA," a b
42+
)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"_pageContent":{"_pageTitle":"5.1 Continuous Mappings","_hash":"2125c437aaac928d5852224ff00a83f9d9776dda","_attributes":{},"_answers":1},"_parentHash":"6c11e3a31b4b8bd07bdef3f87887ab202a568679","_childPageContents":[{"_pageTitle":"8","_hash":"3e8d61043ed9bdb6b3cd4f197f0203bbdcb13db1","_attributes":{"a.md":{"_time":"2020-10-18T14:48:51+09:00","_attributeFile":{"_content":"I'll refer $`\\mathcal{T}`$ as $`\\mathcal{T}_X`$, $`\\mathcal{T}_1`$ as $`\\mathcal{T}_Y`$, $`\\mathcal{T}_2`$ as $`\\mathcal{T}_A`$, $`\\mathcal{T}_3`$ as $`\\mathcal{T}_B`$.\n\nLet's define $`x \\in X`$ and $`U \\in \\mathcal{T}_Y`$ such that $`f(x) \\in U`$. By definition of continuous mapping, there must exists a $`V`$ such that $`x \\in V \\in \\mathcal{T}_X`$ and $`f(x) \\in fV \\subseteq U`$.\n\nIf for any $`x \\in A`$ and any B-induced open set $`U_B \\in \\mathcal{T}_B`$, which must imply existance of $`U \\in \\mathcal{T}_Y`$, such that $`g(x) \\in U_B`$,\n\n![](IMG_44AF9D4BED6C-1.jpeg)\n\n...there exists an A-induced open set $`V_A`$, which must imply existance of $`V \\in \\mathcal{T}_A`$, such that the image $`gV_A`$ satisfies $`g(x) \\in gV_A \\subseteq U_B`$, then $`g`$ must be continuous. What we have to know is that if the image $`gV_A`$is subset of $`U_B`$, in other words, every $`x \\in V_A`$ will satisfiy $`g(x) \\in U_B`$. Let's proove it.\n\n![](IMG_E7FB922B8E70-1.jpeg)\n\n```math\n\\begin{aligned}\n & x \\in V_A \\\\\n & \\rightarrow x \\in V \\\\\n & \\rightarrow g(x) \\in gV \\\\\n & \\rightarrow g(x) \\in \\text{ some } U & \\text{ since } f \\text{ is continuous} \\\\\n & \\rightarrow g(x) \\in U \\cap B & \\text{ since codomain of } g \\text{ is } B \\\\\n & \\rightarrow g(x) \\in U_B\n\\end{aligned}\n```"}},"q.md":{"_time":"2020-04-12T01:08:01+09:00","_attributeFile":{"_content":"Let $`(X,\\mathcal{T})`$ and $`(Y,\\mathcal{T}_1)`$ be topological spaces and $`f:(X,\\mathcal{T}) \\rightarrow (Y,\\mathcal{T}_1)`$ a continuous mapping. Let $`A`$ be a subset of $`X`$, $`\\mathcal{T}_2`$ the induced topology on $`A`$, $`B = f(A)`$, $`\\mathcal{T}_3`$ the induced topology on $`B`$ and $`g:(A,\\mathcal{T}_2) \\rightarrow (B,\\mathcal{T}_3)`$ the restriction of $`f`$ to $`A`$. Prove that $`g`$ is continuous."}}},"_answers":1}]}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"_pageContent":{"_pageTitle":"books","_hash":"2aed5404c83f7a46aa249e0a6328af756b19d513","_attributes":{"q.md":{"_time":"2022-09-25T22:34:28+09:00","_attributeFile":{"_content":"# DON'T PANIC\n\nAlthough it has many omissions and contains much that is apocryphal, or at least wildly inaccurate, but it scores over the other answers over the internet in few important respects. First, the way it is written is very subjective, and second, it has the words DON'T PANIC inscribed in large friendly letters on its home."}}},"_answers":3},"_parentHash":"da39a3ee5e6b4b0d3255bfef95601890afd80709","_childPageContents":[{"_pageTitle":"Topology Without Tears","_hash":"4c1513c92422dc16b3c5f13bd03d34ba0feeb6df","_attributes":{"author.txt":{"_time":"2022-09-25T22:34:28+09:00","_attributeFile":{"_content":"Sidney A. Morris"}}},"_answers":1},{"_pageTitle":"Category Theory For Programmers","_hash":"b614f31d04b3bc2b3d23ee4337475251429e5a9f","_attributes":{"author.txt":{"_time":"2022-09-25T22:34:28+09:00","_attributeFile":{"_content":"Bartosz Milewski"}}},"_answers":2}]}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"_pageContent":{"_pageTitle":"8","_hash":"3e8d61043ed9bdb6b3cd4f197f0203bbdcb13db1","_attributes":{"a.md":{"_time":"2020-10-18T14:48:51+09:00","_attributeFile":{"_content":"I'll refer $`\\mathcal{T}`$ as $`\\mathcal{T}_X`$, $`\\mathcal{T}_1`$ as $`\\mathcal{T}_Y`$, $`\\mathcal{T}_2`$ as $`\\mathcal{T}_A`$, $`\\mathcal{T}_3`$ as $`\\mathcal{T}_B`$.\n\nLet's define $`x \\in X`$ and $`U \\in \\mathcal{T}_Y`$ such that $`f(x) \\in U`$. By definition of continuous mapping, there must exists a $`V`$ such that $`x \\in V \\in \\mathcal{T}_X`$ and $`f(x) \\in fV \\subseteq U`$.\n\nIf for any $`x \\in A`$ and any B-induced open set $`U_B \\in \\mathcal{T}_B`$, which must imply existance of $`U \\in \\mathcal{T}_Y`$, such that $`g(x) \\in U_B`$,\n\n![](IMG_44AF9D4BED6C-1.jpeg)\n\n...there exists an A-induced open set $`V_A`$, which must imply existance of $`V \\in \\mathcal{T}_A`$, such that the image $`gV_A`$ satisfies $`g(x) \\in gV_A \\subseteq U_B`$, then $`g`$ must be continuous. What we have to know is that if the image $`gV_A`$is subset of $`U_B`$, in other words, every $`x \\in V_A`$ will satisfiy $`g(x) \\in U_B`$. Let's proove it.\n\n![](IMG_E7FB922B8E70-1.jpeg)\n\n```math\n\\begin{aligned}\n & x \\in V_A \\\\\n & \\rightarrow x \\in V \\\\\n & \\rightarrow g(x) \\in gV \\\\\n & \\rightarrow g(x) \\in \\text{ some } U & \\text{ since } f \\text{ is continuous} \\\\\n & \\rightarrow g(x) \\in U \\cap B & \\text{ since codomain of } g \\text{ is } B \\\\\n & \\rightarrow g(x) \\in U_B\n\\end{aligned}\n```"}},"q.md":{"_time":"2020-04-12T01:08:01+09:00","_attributeFile":{"_content":"Let $`(X,\\mathcal{T})`$ and $`(Y,\\mathcal{T}_1)`$ be topological spaces and $`f:(X,\\mathcal{T}) \\rightarrow (Y,\\mathcal{T}_1)`$ a continuous mapping. Let $`A`$ be a subset of $`X`$, $`\\mathcal{T}_2`$ the induced topology on $`A`$, $`B = f(A)`$, $`\\mathcal{T}_3`$ the induced topology on $`B`$ and $`g:(A,\\mathcal{T}_2) \\rightarrow (B,\\mathcal{T}_3)`$ the restriction of $`f`$ to $`A`$. Prove that $`g`$ is continuous."}}},"_answers":1},"_parentHash":"2125c437aaac928d5852224ff00a83f9d9776dda","_childPageContents":[]}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"_pageContent":{"_pageTitle":"Topology Without Tears","_hash":"4c1513c92422dc16b3c5f13bd03d34ba0feeb6df","_attributes":{"author.txt":{"_time":"2022-09-25T22:34:28+09:00","_attributeFile":{"_content":"Sidney A. Morris"}}},"_answers":1},"_parentHash":"2aed5404c83f7a46aa249e0a6328af756b19d513","_childPageContents":[{"_pageTitle":"5. Continuous Mappings","_hash":"6c11e3a31b4b8bd07bdef3f87887ab202a568679","_attributes":{},"_answers":1}]}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"_pageContent":{"_pageTitle":"10. Natural Transformations","_hash":"54c6ff9a213b80284619a5afb7859d9d30a444bc","_attributes":{},"_answers":1},"_parentHash":"b614f31d04b3bc2b3d23ee4337475251429e5a9f","_childPageContents":[{"_pageTitle":"5","_hash":"ebe52014d6aaf02a4ddeaa7de59a014eac6634b8","_attributes":{"a.md":{"_time":"2020-10-18T14:48:51+09:00","_attributeFile":{"_content":"Let's proove interchange law.\n\n\n$`\\left( \\beta '\\cdot \\alpha '\\right) \\circ \\left( \\beta \\cdot \\alpha \\right) =\\left( \\beta '\\circ \\beta \\right) \\cdot \\left( \\alpha '\\circ \\alpha \\right)`$\n\n\nLet's say each natural transformation is defined as\n\n\n$`\\alpha :F\\rightarrow F_{2}`$\n$`\\alpha ':F_{2}\\rightarrow F_{3}`$\n$`\\beta :G\\rightarrow G_{2}`$\n$`\\beta ':G_{2}\\rightarrow G_{3}`$\n\n\n![](nat.JPG)\n\nLet's see what we get with first one.\n\n$`\\left( \\beta '\\cdot \\alpha '\\right) \\circ \\left( \\beta \\cdot \\alpha \\right)GF`$ \n\nUsing horizontal composition\n$`=\\left( \\beta'\\cdot \\alpha '\\right) G_{2}F_{2}`$\nAgain, using horizontal composition\n$`=G_{3}F_{3}`$\n\nNow the second one.\n\n$`\\left( \\beta '\\circ \\beta \\right) \\cdot \\left( \\alpha '\\circ \\alpha \\right)GF`$\n\nUnlike previous one, we cannot directly apply the $`(\\alpha' \\circ \\alpha)`$ to $`GF`$. No problem. We can composite horizontally with $`id:G\\rightarrow G`$\n\n$`=\\left( \\beta '\\circ \\beta\\right) \\cdot \\left( \\left( id\\cdot \\alpha '\\right) \\circ \\left( id\\cdot \\alpha \\right) \\right)GF`$\n$`=\\left( \\beta'\\circ \\beta\\right)GF_3`$\n\nSame way but this time with $`id:F\\rightarrow F`$\n\n$`=\\left( \\left( \\beta'\\cdot id\\right) \\circ \\left( \\beta \\cdot id\\right) \\right) GF_{3}`$\n$`=G_3 F_3`$\n\n\nProooven BAMMM"}},"q.md":{"_time":"2019-12-19T21:51:08+09:00","_attributeFile":{"_content":"Write a short essay about how you may enjoy writing down the evident diagrams needed to prove the interchange law.\n"}}},"_answers":1}]}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"_pageContent":{"_pageTitle":"5. Continuous Mappings","_hash":"6c11e3a31b4b8bd07bdef3f87887ab202a568679","_attributes":{},"_answers":1},"_parentHash":"4c1513c92422dc16b3c5f13bd03d34ba0feeb6df","_childPageContents":[{"_pageTitle":"5.1 Continuous Mappings","_hash":"2125c437aaac928d5852224ff00a83f9d9776dda","_attributes":{},"_answers":1}]}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"_pageContent":{"_pageTitle":"answers-db","_hash":"96d719cd412e4a8d03ac3d84cb0e8858f68ec008","_attributes":{},"_answers":3},"_parentHash":"da39a3ee5e6b4b0d3255bfef95601890afd80709","_childPageContents":[{"_pageTitle":"books","_hash":"2aed5404c83f7a46aa249e0a6328af756b19d513","_attributes":{"q.md":{"_time":"2022-09-25T22:34:28+09:00","_attributeFile":{"_content":"# DON'T PANIC\n\nAlthough it has many omissions and contains much that is apocryphal, or at least wildly inaccurate, but it scores over the other answers over the internet in few important respects. First, the way it is written is very subjective, and second, it has the words DON'T PANIC inscribed in large friendly letters on its home."}}},"_answers":3}]}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"_pageContent":{"_pageTitle":"24. F-Algebras","_hash":"b2a3b650e20b0d34511030969274674aaf259e55","_attributes":{},"_answers":1},"_parentHash":"b614f31d04b3bc2b3d23ee4337475251429e5a9f","_childPageContents":[{"_pageTitle":"5","_hash":"c4ad78b11338182da6d1e6b792987c7319ef55d8","_attributes":{"a.md":{"_time":"2020-01-30T14:24:00+09:00","_attributeFile":{"_content":"```haskell\nmodule Un\n ( primes\n ) where\n\nimport Data.List\n\nprimes :: [Int]\nprimes = unfoldr (\\(prime:remains) -> Just (prime, filter (notdiv prime) remains)) [2..]\n where notdiv p n = n `mod` p /= 0\n```"}},"q.md":{"_time":"2020-01-30T14:24:00+09:00","_attributeFile":{"_content":"Use `unfoldr` to generate a list of the first n primes."}}},"_answers":1}]}

0 commit comments

Comments
 (0)