Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Namespace confusion #1

Open
ianchanning opened this issue Dec 20, 2016 · 4 comments
Open

Namespace confusion #1

ianchanning opened this issue Dec 20, 2016 · 4 comments
Labels

Comments

@ianchanning
Copy link

I'm still learning Haskell and QuickCheck, but it seems like your namespaces in your icebreaker example are incorrect:

import Test.Hspec
import Test.Hspec.QuickCheck

Should be:

import Test.Hspec
import Test.QuickCheck

At least that's what is suggested on the Hspec home page:

-- file Spec.hs
import Test.Hspec
import Test.QuickCheck
import Control.Exception (evaluate)

But it could just be the setup that you've got in your project.

@moodmosaic
Copy link
Owner

Thanks! This makes sense so I'll have a look into it. It might take a few days as I'm currently on vacation 😃

@moodmosaic
Copy link
Owner

Let's see...

$ git clone https://github.com/moodmosaic/quickcheck-fscheck-samples.git

Cloning into 'quickcheck-fscheck-samples'...
remote: Counting objects: 569, done.
remote: Total 569 (delta 0), reused 0 (delta 0), pack-reused 569
Receiving objects: 100% (569/569), 25.81 MiB | 3.13 MiB/s, done.
Resolving deltas: 100% (336/336), done.
Checking out files: 100% (448/448), done.

$ stack init --solver

Looking for .cabal or package.yaml files to use to init the project.
Using cabal packages:
- samples-quickcheck.cabal

Selecting the best among 9 snapshots...

* Matches lts-7.14

Selected resolver: lts-7.14
Initialising configuration using resolver: lts-7.14
Total number of user packages considered: 1
Writing configuration to file: stack.yaml
All done.

$stack build

HUnit-1.3.1.2: download
ansi-terminal-0.6.2.3: download
ansi-terminal-0.6.2.3: configure
ansi-terminal-0.6.2.3: build
HUnit-1.3.1.2: configure
HUnit-1.3.1.2: build
HUnit-1.3.1.2: copy/register
async-2.1.1: download
async-2.1.1: configure
ansi-terminal-0.6.2.3: copy/register
async-2.1.1: build
hspec-discover-2.2.4: download
hspec-discover-2.2.4: configure
hspec-discover-2.2.4: build
async-2.1.1: copy/register
hspec-expectations-0.7.2: download
hspec-expectations-0.7.2: configure
hspec-expectations-0.7.2: build
hspec-discover-2.2.4: copy/register
hspec-expectations-0.7.2: copy/register
random-1.1: using precompiled package
tf-random-0.5: using precompiled package
setenv-0.1.1.3: download
setenv-0.1.1.3: configure
QuickCheck-2.8.2: download
setenv-0.1.1.3: build
QuickCheck-2.8.2: configure
setenv-0.1.1.3: copy/register
QuickCheck-2.8.2: build
QuickCheck-2.8.2: copy/register
quickcheck-io-0.1.4: download
quickcheck-io-0.1.4: configure
quickcheck-io-0.1.4: build
quickcheck-io-0.1.4: copy/register
hspec-core-2.2.4: download
hspec-core-2.2.4: configure
hspec-core-2.2.4: build
hspec-core-2.2.4: copy/register
hspec-2.2.4: download
hspec-2.2.4: configure
hspec-2.2.4: build
hspec-2.2.4: copy/register
samples-quickcheck-0.0.0: configure
Configuring samples-quickcheck-0.0.0...
samples-quickcheck-0.0.0: build
Preprocessing library samples-quickcheck-0.0.0...
samples-quickcheck-0.0.0: copy/register
Installing library in
C:\Users\Nikos\Documents\Cherry\Free\quickcheck-fscheck-samples\samples-quickche
ck\.stack-work\install\eb32346d\lib\x86_64-windows-ghc-8.0.1\samples-quickcheck-
0.0.0-1l6ir3fQOV8FrOhncVDGQl
Registering samples-quickcheck-0.0.0...
Completed 13 action(s).

$ stack test

samples-quickcheck-0.0.0: unregistering (components added: test:spec)
samples-quickcheck-0.0.0: configure (lib + test)
Configuring samples-quickcheck-0.0.0...
samples-quickcheck-0.0.0: build (lib + test)
Preprocessing library samples-quickcheck-0.0.0...
Preprocessing test suite 'spec' for samples-quickcheck-0.0.0...
[1 of 2] Compiling GettingStartedSpec ( tests\GettingStartedSpec.hs, .stack-work
\dist\b7fec021\build\spec\spec-tmp\GettingStartedSpec.o )
[2 of 2] Compiling Main             ( tests\Spec.hs, .stack-work\dist\b7fec021\b
uild\spec\spec-tmp\Main.o )
Linking .stack-work\dist\b7fec021\build\spec\spec.exe ...
Warning: module not listed in samples-quickcheck.cabal for 'spec' component (add
 to other-modules): GettingStartedSpec
samples-quickcheck-0.0.0: copy/register
Installing library in
C:\Users\Nikos\Documents\Cherry\Free\quickcheck-fscheck-samples\samples-quickche
ck\.stack-work\install\eb32346d\lib\x86_64-windows-ghc-8.0.1\samples-quickcheck-
0.0.0-1l6ir3fQOV8FrOhncVDGQl
Registering samples-quickcheck-0.0.0...
samples-quickcheck-0.0.0: test (suite: spec)


GettingStarted
  icebreaker
    icebreaker

Finished in 0.0060 seconds
1 example, 0 failures

Completed 2 action(s).

@ianchanning
Copy link
Author

Hmmm odd. I'll see if I can get the HSpec examples working using import Test.Hspec.QuickCheck

@moodmosaic
Copy link
Owner

Actually this (the proposed one) makes sense:

import Test.Hspec
import Test.QuickCheck

Because essentially it uses QuickCheck for writing the actual property-based tests and Hspec for discovering and running the tests. — Probably the examples here are based on an old version of HSpec(?)


FWIW, nowadays I'm trying to get rid of all testing-tools, because with QuickCheck (and Jack) I use them only as a test-discovery mechanism. Ideally, I'd like to end up doing something like this in xmonad. 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants