小编Mik*_*ris的帖子

在F#中,如何将集合传递给xUnit的InlineData属性

我想要将列表,数组和/或seq用作xUnit的InlineData的参数.

在C#中,我可以这样做:

using Xunit; //2.1.0

namespace CsTests
{
    public class Tests
    {
        [Theory]
        [InlineData(new[] {1, 2})]
        public void GivenCollectionItMustPassItToTest(int[] coll)
        {
            Assert.Equal(coll, coll);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

在F#我有这个:

namespace XunitTests

module Tests =
  open Xunit //2.1.0

  [<Theory>]
  [<InlineData(8)>]
  [<InlineData(42)>]
  let ``given a value it must give it to the test`` (value : int) =
    Assert.Equal(value, value)

  [<Theory>]
  [<InlineData([1; 2])>]
  let ``given a list it should be able to pass it to the test``
  (coll : int list) =
    Assert.Equal<int list>(coll, coll) …
Run Code Online (Sandbox Code Playgroud)

.net tdd f# xunit

8
推荐指数
4
解决办法
1849
查看次数

在Elm中,实现自己的toString的正确方法是什么

在Elm中,获取模型和实现toString函数的正确方法是什么?

我正在寻找的类型是toString : Model -> String,我能够使用类型的类似函数,toStr : Model -> String但我认为我希望调用该函数toString.

示例程序(Coin Changer kata):

module CoinChanger where

import Html exposing (..)
import StartApp.Simple as StartApp
import Signal exposing (Address)
import Html.Attributes exposing (..)
import Html.Events exposing (on, targetValue)
import String


---- MAIN ----


main =
  StartApp.start 
  {
       model = emptyModel
      ,update = update
      ,view = view
  }


---- Model ----


type alias Model =
    {
        change : List Int
    }


emptyModel : Model
emptyModel = …
Run Code Online (Sandbox Code Playgroud)

elm

7
推荐指数
2
解决办法
1294
查看次数

未知变量 +

在 Little Typer 第 2 章中,第 100 帧给出了以下定义:

(claim pearwise+
  (? Pear Pear
     Pear))

(define pearwise+
  (? (anjou bosc)
    (elim-Pear anjou
      (? (a1 d1)
        (elim-Pear bosc
          (? (a2 d2)
            (cons
              (+ a1 a2)
              (+ d1 d2))))))))
Run Code Online (Sandbox Code Playgroud)

当我运行它时,我收到以下错误:

Unknown variable +
Run Code Online (Sandbox Code Playgroud)

怎么了?

racket pie-lang

5
推荐指数
1
解决办法
137
查看次数

在Coq中如何重复举证策略?

我想通过添加一个定理来扩展Coq'Art中的练习6.10,该定理是:对于不是1月的所有月份,is_January将等于false。

我对月份的定义如下所示:

 Inductive month : Set :=
   | January : month
   | February : month
   | March : month
   | April : month
   | May : month
   | June : month
   | July : month
   | August : month
   | September : month
   | October : month
   | November : month
   | December : month
  .

Check month_rect.
Run Code Online (Sandbox Code Playgroud)

我对is_January的定义如下所示:

Definition is_January (m : month) : Prop :=
  match m with
  | January => True
  | other   => False
  end.
Run Code Online (Sandbox Code Playgroud)

我正在做以下测试,以证明它是正确的。 …

coq coq-tactic

2
推荐指数
1
解决办法
793
查看次数

clojure循环在map-indexed中返回nil

我正试图在clojure中编写基于Fizz Buzz的循环.它似乎适用于不是Fizz或Buzz的值,但对于Fizz和Buzz的值,它返回nil.

码:

(ns fizz-buzz.core
  (:gen-class))

(defn fizz-buzz [value]
  (let [fizz (cycle ["" "" "Fizz"])
        buzz (cycle ["" "" "" "" "Buzz"])
        fb (map str fizz buzz)]
    (nth (map-indexed 
           (fn [i v] 
             (if (clojure.string/blank? v)
               (str (+ i 1)
               v)))
           fb)
         (- value 1)))
Run Code Online (Sandbox Code Playgroud)

测试:

(ns fizz-buzz.core-test
  (:require [clojure.test :refer :all]
            [fizz-buzz.core :refer :all]))

(deftest value-2-will-return-2 
  (testing "2 will return the string 2"
    (is (= "2" (fizz-buzz 2)))))

(deftest value-4-will-return-4 
  (testing "4 will return the string 4"
    (is (= "4" …
Run Code Online (Sandbox Code Playgroud)

clojure

1
推荐指数
1
解决办法
122
查看次数

标签 统计

.net ×1

clojure ×1

coq ×1

coq-tactic ×1

elm ×1

f# ×1

pie-lang ×1

racket ×1

tdd ×1

xunit ×1