My attempt at extending Mike's Let's make a bar chart, III example with updates.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using MongoDB.Bson; | |
using MongoDB.Driver; | |
using NSubstitute; | |
using NSubstitute.ExceptionExtensions; | |
using Xunit; | |
namespace NSubWorkshop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A type [T] with an associative binary operation. | |
* | |
* Must satisfy the associative property: | |
* `combine(combine(a, b), c) == combine(a, combine(b, c))` | |
*/ | |
interface Semigroup<T> { | |
fun combine(a: T, b: T): T |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DiagnosticsSubstitutionContext : ISubstitutionContext | |
{ | |
[ThreadStatic] | |
private static IList<IArgumentSpecification> LastDequeuedList; | |
private static ConcurrentDictionary<IArgumentSpecification, ArgumentInfo> ArgumentInfos { get; } = new ConcurrentDictionary<IArgumentSpecification, ArgumentInfo>(); | |
private class ArgumentInfo | |
{ | |
public string CreationStack { get; } | |
public int DequeueCounter { get; set; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Based on https://gist.github.com/evancz/78293dc6a4ac2547676c | |
type alias Lens s a = | |
{ get : s -> a | |
, set : a -> s -> s | |
} | |
modify : Lens s a -> (a -> a) -> s -> s | |
modify l f s = | |
l.set (f (l.get s)) s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Based on example from http://fsharpforfunandprofit.com/posts/property-based-testing/ | |
[<Test>] | |
let repro() = | |
let seed = (771943725,296061824) // seed reported by failed FsCheck output | |
let config = { | |
Config.QuickThrowOnFailure with | |
Replay = Random.StdGen seed |> Some | |
} | |
Check.One (config, prop) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Some function that takes a number and a string | |
ghci> let f a b = show (a+1) ++ " " ++ b | |
ghci> :t f | |
f :: (Show a, Num a) => a -> [Char] -> [Char] | |
-- Some type with a number of fields we want to read | |
ghci> data Option = Option { number :: Int, label :: String } deriving (Show, Eq) | |
ghci> let o = Option 1 "hi" | |
-- Read value of each field from Option and pass to `f` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Reference: https://www.igvita.com/2007/02/13/building-dynamic-webrick-servers-in-ruby/ | |
require 'webrick' | |
class Echo < WEBrick::HTTPServlet::AbstractServlet | |
def do_GET(request, response) | |
puts request | |
response.status = 200 | |
end | |
def do_POST(request, response) | |
puts request |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import UIKit | |
import XCTest | |
// INTRODUCTION | |
// Console<T> is a type representing programs that can interact with the console (i.e. read from stdin, write to stdout), | |
// to produce a value of some type T. | |
// | |
// A Console<()> program is one that returns void ( a.k.a. Unit, written "()" ). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module DaveSquared.Sample | |
open Xunit | |
let incr x = x+1 | |
// Test using Unquote | |
open Swensen.Unquote | |
[<Fact>] |
NewerOlder