# -*- coding: utf-8 -*-
require File.dirname(__FILE__) + '/../../spec_helper'
require 'mspec/runner/formatters/junit'
require 'mspec/runner/example'

describe JUnitFormatter, "#initialize" do
  it "permits zero arguments" do
    lambda { JUnitFormatter.new }.should_not raise_error
  end

  it "accepts one argument" do
    lambda { JUnitFormatter.new nil }.should_not raise_error
  end
end

describe JUnitFormatter, "#print" do
  before :each do
    $stdout = IOStub.new
    @out = IOStub.new
    File.stub(:open).and_return(@out)
    @formatter = JUnitFormatter.new "some/file"
  end

  after :each do
    $stdout = STDOUT
  end

  it "writes to $stdout if #switch has not been called" do
    @formatter.print "begonias"
    $stdout.should == "begonias"
    @out.should == ""
  end

  it "writes to the file passed to #initialize once #switch has been called" do
    @formatter.switch
    @formatter.print "begonias"
    $stdout.should == ""
    @out.should == "begonias"
  end

  it "writes to $stdout once #switch is called if no file was passed to #initialize" do
    formatter = JUnitFormatter.new
    formatter.switch
    formatter.print "begonias"
    $stdout.should == "begonias"
    @out.should == ""
  end
end

describe JUnitFormatter, "#finish" do
  before :each do
    @tally = double("tally").as_null_object
    @counter = double("counter").as_null_object
    @tally.stub(:counter).and_return(@counter)
    TallyAction.stub(:new).and_return(@tally)

    @timer = double("timer").as_null_object
    TimerAction.stub(:new).and_return(@timer)

    $stdout = IOStub.new
    context = ContextState.new "describe"
    @state = ExampleState.new(context, "it")

    @formatter = JUnitFormatter.new
    @formatter.stub(:backtrace).and_return("")
    MSpec.stub(:register)
    @formatter.register

    exc = ExceptionState.new @state, nil, MSpecExampleError.new("broken")
    exc.stub(:backtrace).and_return("path/to/some/file.rb:35:in method")
    @formatter.exception exc
    @formatter.after @state
  end

  after :each do
    $stdout = STDOUT
  end

  it "calls #switch" do
    @formatter.should_receive(:switch)
    @formatter.finish
  end

  it "outputs a failure message and backtrace" do
    @formatter.finish
    $stdout.should include 'message="error in describe it" type="error"'
    $stdout.should include "MSpecExampleError: broken\n"
    $stdout.should include "path/to/some/file.rb:35:in method"
  end

  it "encodes message and backtrace in latin1 for jenkins" do
    exc = ExceptionState.new @state, nil, MSpecExampleError.new("broken…")
    exc.stub(:backtrace).and_return("path/to/some/file.rb:35:in methød")
    @formatter.exception exc
    @formatter.finish
    $stdout.should =~ /MSpecExampleError: broken((\.\.\.)|\?)\n/
    $stdout.should =~ /path\/to\/some\/file\.rb:35:in meth(\?|o)d/
  end

  it "outputs an elapsed time" do
    @timer.should_receive(:elapsed).and_return(4.2)
    @formatter.finish
    $stdout.should include 'time="4.2"'
  end

  it "outputs overall elapsed time" do
    @timer.should_receive(:elapsed).and_return(4.2)
    @formatter.finish
    $stdout.should include 'timeCount="4.2"'
  end

  it "outputs the number of examples as test count" do
    @counter.should_receive(:examples).and_return(9)
    @formatter.finish
    $stdout.should include 'tests="9"'
  end

  it "outputs overall number of examples as test count" do
    @counter.should_receive(:examples).and_return(9)
    @formatter.finish
    $stdout.should include 'testCount="9"'
  end

  it "outputs a failure count" do
    @counter.should_receive(:failures).and_return(2)
    @formatter.finish
    $stdout.should include 'failureCount="2"'
  end

  it "outputs overall failure count" do
    @counter.should_receive(:failures).and_return(2)
    @formatter.finish
    $stdout.should include 'failures="2"'
  end

  it "outputs an error count" do
    @counter.should_receive(:errors).and_return(1)
    @formatter.finish
    $stdout.should include 'errors="1"'
  end

  it "outputs overall error count" do
    @counter.should_receive(:errors).and_return(1)
    @formatter.finish
    $stdout.should include 'errorCount="1"'
  end
end


/*
 * Copyright (C) 2016 Lightbend Inc. <http://www.lightbend.com>
 */

package akka.stream.contrib

import akka.actor.ActorSystem
import akka.pattern.after
import akka.stream.ActorMaterializer
import akka.stream.contrib.SwitchMode.{Close, Open}
import akka.stream.scaladsl.{Keep, Sink, Source}
import akka.stream.testkit.scaladsl._
import org.scalatest._
import org.scalatest.Matchers._
import org.scalatest.concurrent.ScalaFutures
import scala.language.postfixOps

import scala.concurrent.duration._

class ValveSpec extends WordSpec with ScalaFutures {

  implicit val system = ActorSystem()
  implicit val materializer = ActorMaterializer()
  implicit val executionContext = materializer.executionContext

  "A closed valve" should {

    "emit only 3 elements into a sequence when the valve is switched to open" in {

      val (switchFut, seq) = Source(1 to 3)
        .viaMat(new Valve(SwitchMode.Close))(Keep.right)
        .toMat(Sink.seq)(Keep.both)
        .run()

      whenReady(switchFut) { switch =>
        after(100 millis, system.scheduler) {
          switch.flip(Open)
        }.futureValue shouldBe true

        seq.futureValue should contain inOrder (1, 2, 3)
      }
    }

    "emit only 5 elements when the valve is switched to open" in {
      val (switchFut, probe) = Source(1 to 5)
        .viaMat(new Valve(SwitchMode.Close))(Keep.right)
        .toMat(TestSink.probe[Int])(Keep.both)
        .run()

      whenReady(switchFut) { switch =>
        probe.request(2)
        probe.expectNoMsg(100 millis)

        whenReady(switch.flip(Open)) {
          _ shouldBe true
        }

        probe.expectNext shouldBe 1
        probe.expectNext shouldBe 2

        probe.request(3)
        probe.expectNext shouldBe 3
        probe.expectNext shouldBe 4
        probe.expectNext shouldBe 5

        probe.expectComplete()
      }
    }

    "emit only 3 elements when the valve is switch to open/close/open" in {
      val ((sourceProbe, switchFut), sinkProbe) = TestSource
        .probe[Int]
        .viaMat(Valve())(Keep.both)
        .toMat(TestSink.probe[Int])(Keep.both)
        .run()

      whenReady(switchFut) { switch =>
        sinkProbe.request(1)
        whenReady(switch.flip(Close)) {
          _ shouldBe true
        }
        sourceProbe.sendNext(1)
        sinkProbe.expectNoMsg(100 millis)

        whenReady(switch.flip(Open)) {
          _ shouldBe true
        }
        sinkProbe.expectNext shouldEqual 1

        whenReady(switch.flip(Close)) {
          _ shouldBe true
        }
        whenReady(switch.flip(Open)) {
          _ shouldBe true
        }
        sinkProbe.expectNoMsg(100 millis)

        sinkProbe.request(1)
        sinkProbe.request(1)
        sourceProbe.sendNext(2)
        sourceProbe.sendNext(3)
        sourceProbe.sendComplete()

        sinkProbe.expectNext shouldBe 2
        sinkProbe.expectNext shouldBe 3

        sinkProbe.expectComplete()
      }
    }

    "return false when the valve is already closed" in {
      val (switchFut, probe) = Source(1 to 5)
        .viaMat(Valve(SwitchMode.Close))(Keep.right)
        .toMat(TestSink.probe[Int])(Keep.both)
        .run()

      whenReady(switchFut) { switch =>
        whenReady(switch.flip(Close)) { element =>
          element should be(false)
        }
        whenReady(switch.flip(Close)) { element =>
          element should be(false)
        }
      }
    }

    "emit nothing when the source is empty" in {
      val (switch, seq) = Source.empty
        .viaMat(Valve(SwitchMode.Close))(Keep.right)
        .toMat(Sink.seq)(Keep.both)
        .run()

      whenReady(seq, timeout(200 millis)) {
        _ shouldBe empty
      }
    }

    "emit nothing when the source is failing" in {
      val (switch, seq) = Source
        .failed(new IllegalArgumentException("Fake exception"))
        .viaMat(Valve(SwitchMode.Close))(Keep.right)
        .toMat(Sink.seq)(Keep.both)
        .run()

      whenReady(seq.failed) { e =>
        e shouldBe an[IllegalArgumentException]
      }
    }

    "not pull elements again when opened and closed and re-opened" in {

      val (probe, switchFut, resultFuture) = TestSource
        .probe[Int]
        .viaMat(Valve(SwitchMode.Close))(Keep.both)
        .toMat(Sink.head)((l, r) => (l._1, l._2, r))
        .run()

      whenReady(switchFut) { switch =>
        val result = for {
          _ <- switch.flip(SwitchMode.Open)
          _ <- switch.flip(SwitchMode.Close)
          _ <- switch.flip(SwitchMode.Open)
          _ = probe.sendNext(1)
          _ = probe.sendComplete()
          r <- resultFuture
        } yield r

        whenReady(result) {
          _ shouldBe 1
        }
      }
    }

    "be in closed state" in {
      val (switchFut, seq) = Source(1 to 3)
        .viaMat(new Valve(SwitchMode.Close))(Keep.right)
        .toMat(Sink.seq)(Keep.both)
        .run()

      whenReady(switchFut) { switch =>
        whenReady(switch.getMode()) {
          _ shouldBe Close
        }
      }
    }

  }

  "A opened valve" should {

    "emit 5 elements after it has been close/open" in {
      val (switchFut, probe) = Source(1 to 5)
        .viaMat(Valve())(Keep.right)
        .toMat(TestSink.probe[Int])(Keep.both)
        .run()

      whenReady(switchFut) { switch =>
        probe.request(2)
        probe.expectNext() shouldBe 1
        probe.expectNext() shouldBe 2

        whenReady(switch.flip(Close)) {
          _ shouldBe true
        }

        probe.request(1)
        probe.expectNoMsg(100 millis)

        whenReady(switch.flip(Open)) {
          _ shouldBe true
        }
        probe.expectNext() shouldBe 3

        probe.request(2)
        probe.expectNext() shouldBe 4
        probe.expectNext() shouldBe 5

        probe.expectComplete()
      }
    }

    "return false when the valve is already opened" in {
      val (switchFut, probe) = Source(1 to 5)
        .viaMat(Valve())(Keep.right)
        .toMat(TestSink.probe[Int])(Keep.both)
        .run()

      whenReady(switchFut) { switch =>
        whenReady(switch.flip(Open)) {
          _ shouldBe false
        }
        whenReady(switch.flip(Open)) {
          _ shouldBe false
        }
      }
    }

    "emit only 3 elements into a sequence" in {

      val (switch, seq) = Source(1 to 3)
        .viaMat(Valve())(Keep.right)
        .toMat(Sink.seq)(Keep.both)
        .run()

      whenReady(seq, timeout(200 millis)) {
        _ should contain inOrder (1, 2, 3)
      }
    }

    "emit nothing when the source is empty" in {
      val (switch, seq) = Source.empty
        .viaMat(Valve())(Keep.right)
        .toMat(Sink.seq)(Keep.both)
        .run()

      whenReady(seq, timeout(200 millis)) {
        _ shouldBe empty
      }

    }

    "emit nothing when the source is failing" in {
      val (switch, seq) = Source
        .failed(new IllegalArgumentException("Fake exception"))
        .viaMat(Valve())(Keep.right)
        .toMat(Sink.seq)(Keep.both)
        .run()

      whenReady(seq.failed) { e =>
        e shouldBe an[IllegalArgumentException]
      }
    }

    "not pull elements again when closed and re-opened" in {

      val (probe, switchFut, resultFuture) = TestSource
        .probe[Int]
        .viaMat(Valve())(Keep.both)
        .toMat(Sink.head)((l, r) => (l._1, l._2, r))
        .run()

      whenReady(switchFut) { switch =>
        val result = for {
          _ <- switch.flip(SwitchMode.Close)
          _ <- switch.flip(SwitchMode.Open)
          _ = probe.sendNext(1)
          _ = probe.sendComplete()
          r <- resultFuture
        } yield r

        whenReady(result) {
          _ shouldBe 1
        }
      }
    }

    "be in open state" in {
      val (switchFut, probe) = Source(1 to 5)
        .viaMat(Valve())(Keep.right)
        .toMat(TestSink.probe[Int])(Keep.both)
        .run()
      whenReady(switchFut) { switch =>
        whenReady(switch.getMode()) {
          _ shouldBe Open
        }
      }
    }

  }
}


<!DOCTYPE html>

	<meta charset="utf-8" />
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no"/>
	<title>Sewise Player</title>

Fork it on GitHub


vcpkg_from_github(
    OUT_SOURCE_PATH SOURCE_PATH
    REPO xiph/vorbis
    REF v1.3.7
    SHA512 bfb6f5dbfd49ed38b2b08b3667c06d02e68f649068a050f21a3cc7e1e56b27afd546aaa3199c4f6448f03f6e66a82f9a9dc2241c826d3d1d4acbd38339b9e9fb
    HEAD_REF master
    PATCHES
        0001-Dont-export-vorbisenc-functions.patch
)

vcpkg_configure_cmake(
    SOURCE_PATH ${SOURCE_PATH}
    PREFER_NINJA
)

vcpkg_install_cmake()
vcpkg_fixup_cmake_targets(
    CONFIG_PATH lib/cmake/Vorbis
    TARGET_PATH share/Vorbis
)

file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)

# Handle copyright
configure_file(${SOURCE_PATH}/COPYING ${CURRENT_PACKAGES_DIR}/share/${PORT}/copyright COPYONLY)

vcpkg_copy_pdbs()

if(WIN32 AND (NOT MINGW))
    vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/vorbis.pc" "-lm" "")
    vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/lib/pkgconfig/vorbis.pc" "-lm" "")
endif()
vcpkg_fixup_pkgconfig()