├── d ├── .gitignore ├── dub.json ├── test │ └── GildedRoseUnitTests.d └── src │ └── GildedRoseTextTests.d ├── rust ├── .gitignore ├── Cargo.lock ├── Cargo.toml └── src │ ├── gildedrose │ └── test.rs │ └── main.rs ├── elixir ├── .gitignore ├── config │ └── config.exs ├── test │ ├── test_helper.exs │ └── gilded_rose_test.exs ├── lib │ └── item.ex └── mix.exs ├── perl6 ├── .gitignore ├── lib │ ├── Item.pm6 │ └── GildedRose.pm6 ├── test.p6 └── texttest_fixture.p6 ├── texttests ├── ThirtyDays │ ├── stderr.gr │ ├── options.gr │ └── ._options.gr ├── testsuite.gr ├── environment.gr └── config.gr ├── erlang ├── .gitignore ├── src │ └── gilded_rose.app.src ├── rebar.config ├── rebar3 ├── include │ └── gilded_rose.hrl ├── README.md └── test │ └── gilded_rose_tests.erl ├── js-jest ├── .gitignore ├── test │ ├── gilded_rose.test.js │ └── texttest_fixture.js ├── README.md └── package.json ├── js-mocha ├── .gitignore ├── test │ ├── test_gilded_rose.js │ └── texttest_fixture.js └── package.json ├── ruby ├── .gitignore ├── .rspec ├── .loadpath ├── .buildpath ├── gilded_rose_tests.rb ├── gilded_rose_spec.rb ├── .project ├── texttest_fixture.rb └── gilded_rose.rb ├── js-jasmine ├── .gitignore ├── spec │ ├── support │ │ └── jasmine.json │ ├── gilded_rose_spec.js │ └── texttest_fixture.js └── package.json ├── C ├── run-once.sh ├── README.txt ├── GildedRose.h ├── GildedRoseUnitTests.cc ├── GildedRoseTextTests.c └── Makefile ├── Java-Spock ├── .gitignore ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── build.gradle └── src │ ├── main │ └── java │ │ └── com │ │ └── gildedrose │ │ ├── Item.java │ │ └── TexttestFixture.java │ └── test │ └── groovy │ └── com │ └── gildedrose │ └── GildedRoseSpec.groovy ├── scala ├── project │ ├── .gitignore │ └── build.properties ├── src │ ├── main │ │ └── scala │ │ │ └── com │ │ │ └── gildedrose │ │ │ ├── Item.scala │ │ │ └── GildedRose.scala │ └── test │ │ └── scala │ │ └── com │ │ └── gildedrose │ │ ├── GildedRoseTest.scala │ │ └── TexttestFixture.scala ├── build.sbt └── .gitignore ├── COBOL └── mf │ ├── src │ ├── .gitignore │ └── .project │ └── test │ ├── .gitignore │ ├── .project │ └── TestGildedRose.cbl ├── Java ├── settings.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── .gitignore ├── src │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── gildedrose │ │ │ ├── GildedRoseTest.java │ │ │ └── TexttestFixture.java │ └── main │ │ └── java │ │ └── com │ │ └── gildedrose │ │ └── Item.java ├── build.gradle └── pom.xml ├── cpp ├── .gitignore ├── test │ ├── cpp_catch2_approvaltest │ │ ├── GildedRoseCatch2ApprovalTests.GildedRoseApprovalTests.approved.txt │ │ ├── CMakeLists.txt │ │ └── GildedRoseCatch2ApprovalTests.cc │ ├── cpp_googletest_approvaltest │ │ ├── GildedRoseGoogletestApprovalTests.GildedRoseApprovalTests.VerifyCombinations.approved.txt │ │ ├── googletest_approval_main.cc │ │ ├── CMakeLists.txt │ │ └── GildedRoseGoogletestApprovalTests.cc │ ├── CMakeLists.txt │ ├── cpp_googletest_unittest │ │ ├── GildedRoseGoogletestUnitTests.cc │ │ └── CMakeLists.txt │ ├── cpp_catch2_unittest │ │ ├── GildedRoseCatch2UnitTests.cc │ │ └── CMakeLists.txt │ └── cpp_texttest │ │ ├── CMakeLists.txt │ │ └── GildedRoseTextTests.cc ├── lib │ ├── CMakeLists.txt │ └── ApprovalTests.hpp ├── src │ ├── CMakeLists.txt │ └── GildedRose.h └── CMakeLists.txt ├── haskell ├── stack.yaml ├── test │ ├── Spec.hs │ └── GildedRoseSpec.hs ├── .gitignore ├── README.md ├── gilded-rose.cabal └── src │ └── Main.hs ├── xslt ├── .gitignore ├── gilded_rose.dtd ├── README.md ├── texttest_fixture.xml └── xsltunit-0.2 │ └── xsltunit_report.xsl ├── cpp-catch2 ├── test │ ├── ApprovalTests.hpp │ ├── main.cpp │ └── gildedrose_catch.cpp ├── .gitignore ├── src │ └── GildedRose.h ├── README.md └── CMakeLists.txt ├── python ├── .gitignore ├── test_gilded_rose.py ├── texttest_fixture.py └── gilded_rose.py ├── .gitignore ├── Ada ├── .gitignore ├── README.txt ├── gilded_rose_tests.ads ├── items.ads ├── gilded_rose_tester.adb ├── gilded_rose.ads ├── Makefile ├── items.adb ├── gilded_rose_tests.adb └── program.adb ├── swift ├── .gitignore ├── Tests │ ├── LinuxMain.swift │ └── GildedRoseTests │ │ ├── XCTestManifests.swift │ │ └── GildedRoseTests.swift ├── Sources │ ├── GildedRose │ │ └── Item.swift │ └── GildedRoseApp │ │ └── main.swift └── Package.swift ├── elm ├── .gitignore ├── src │ ├── Main.elm │ └── GildedRose.elm ├── README.md ├── tests │ └── GildedRoseTest.elm └── elm.json ├── php5 ├── test │ ├── bootstrap.php │ └── gilded_rose_test.php ├── .settings │ ├── org.eclipse.php.core.prefs │ ├── org.eclipse.wst.common.project.facet.core.xml │ └── com.piece_framework.makegood.core.prefs ├── .buildpath ├── phpunit.xml ├── .project └── src │ └── texttest_fixture.php ├── php7 ├── test │ ├── bootstrap.php │ └── GildedRoseTest.php ├── composer.json ├── src │ └── Item.php ├── phpunit.xml ├── fixtures │ └── texttest_fixture.php └── README.md ├── Groovy ├── .idea │ ├── copyright │ │ └── profiles_settings.xml │ ├── modules.xml │ ├── compiler.xml │ └── misc.xml ├── src │ └── com │ │ └── gildedrose │ │ ├── GildedRoseTest.groovy │ │ ├── Item.groovy │ │ └── TexttestFixture.groovy ├── Groovy.iml └── README.txt ├── plantuml ├── gilded-rose.png ├── workshop-materials │ └── testcases.pdf ├── history │ ├── 01_lower-both-values.puml │ ├── 02_sell-by-passed.puml │ ├── 03_quality-never-negative.puml │ ├── 04_aged-brie.puml │ ├── 05_quality-max-50.puml │ ├── 06_sulfuras.puml │ └── 07_backstage-passes.puml ├── readme.md └── gilded-rose.puml ├── TypeScript ├── test │ ├── mocha.opts │ ├── gilded-rose.spec.ts │ └── golden-master-text-test.ts ├── .gitignore ├── tsconfig.json └── package.json ├── pascal ├── .gitignore ├── ROSE_T.PAS ├── README.md └── TEXTTEST.PAS ├── Kotlin ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── src │ ├── main │ │ └── kotlin │ │ │ └── com │ │ │ └── gildedrose │ │ │ └── Item.kt │ └── test │ │ └── kotlin │ │ └── com │ │ └── gildedrose │ │ ├── GildedRoseTest.kt │ │ └── TexttestFixture.kt ├── .gitignore └── build.gradle ├── plpgsql ├── pgtap │ ├── initialize.sh │ └── test_case_update_quality.sql ├── src │ ├── item.sql │ └── new_item.sql ├── initializeDatabase.sh ├── pgunit │ └── initialize.sh ├── docker-compose.yml ├── initializeDocker.sh └── Dockerfile ├── dart ├── pubspec.yaml ├── .gitignore ├── test │ └── gilded_rose_test.dart ├── bin │ └── main.dart └── lib │ └── gilded_rose.dart ├── plsql ├── run_tests.sql ├── create_user_if_needed.sql ├── new_item.sql ├── texttest.pks ├── ut_update_quality.pks ├── item.sql ├── ut_update_quality.pkb └── update_quality.sql ├── c99 ├── run-once-cmake.sh ├── GildedRose.h ├── test_unity_gildedrose.c ├── test_rose.c ├── test_main.c ├── CMakeLists.txt ├── GildedRoseTextTests.c └── Makefile ├── csharp ├── App.config ├── Item.cs ├── packages.config ├── GildedRoseTest.cs ├── ApprovalTest.cs ├── csharp.sln ├── Properties │ └── AssemblyInfo.cs └── Program.cs ├── R ├── runit_gilded_rose.R ├── test_setup.R ├── item.R ├── .project ├── texttest_fixture.R └── gilded_rose.R ├── fsharp ├── GildedRose │ └── App.config ├── GildedRose.Tests │ ├── packages.config │ └── GildedRoseTest.fs └── GildedRose.sln ├── csharpcore ├── Item.cs ├── GildedRoseTest.cs ├── csharpcore.csproj ├── ApprovalTest.cs └── Program.cs ├── sql ├── structure │ └── postgreSQL │ │ └── create.sql ├── README.md ├── test │ └── data │ │ └── load.sql └── code │ └── update_quality.sql ├── .bettercodehub.yml ├── scheme ├── gilded-rose-test.scm ├── README.md ├── texttest-fixture.scm └── assert.scm ├── go ├── README.md ├── gilded-rose_test.go ├── texttest_fixture.go └── gilded-rose.go ├── perl ├── Item.pm ├── test.pl └── texttest_fixture.pl ├── fsharp-core ├── GildedRose.UnitTests │ ├── Tests.fs │ └── GildedRose.UnitTests.fsproj ├── GildedRose │ └── GildedRose.fsproj └── GildedRose.ApprovalTests │ ├── Tests.fs │ └── GildedRose.ApprovalTests.fsproj ├── Delphi ├── .gitattributes ├── README.md ├── GildedRoseTests.pas ├── Item.pas ├── TextTestFixture.dpr ├── UnitTests.dpr ├── .gitignore └── GildedRose.groupproj ├── abap └── README.md ├── GildedRoseRequirements_zh.txt └── license.txt /d/.gitignore: -------------------------------------------------------------------------------- 1 | .dub -------------------------------------------------------------------------------- /rust/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | -------------------------------------------------------------------------------- /elixir/.gitignore: -------------------------------------------------------------------------------- 1 | _build/ 2 | -------------------------------------------------------------------------------- /perl6/.gitignore: -------------------------------------------------------------------------------- 1 | lib/.precomp 2 | -------------------------------------------------------------------------------- /texttests/ThirtyDays/stderr.gr: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /erlang/.gitignore: -------------------------------------------------------------------------------- 1 | /_build 2 | /*.txt -------------------------------------------------------------------------------- /js-jest/.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules/ 2 | -------------------------------------------------------------------------------- /js-mocha/.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules/ 2 | -------------------------------------------------------------------------------- /ruby/.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | *.iml 3 | -------------------------------------------------------------------------------- /texttests/ThirtyDays/options.gr: -------------------------------------------------------------------------------- 1 | 30 2 | -------------------------------------------------------------------------------- /elixir/config/config.exs: -------------------------------------------------------------------------------- 1 | use Mix.Config 2 | -------------------------------------------------------------------------------- /js-jasmine/.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules/ 2 | -------------------------------------------------------------------------------- /C/run-once.sh: -------------------------------------------------------------------------------- 1 | make 2 | ./GildedRoseTextTests 3 | -------------------------------------------------------------------------------- /elixir/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /Java-Spock/.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | .gradle/ 3 | build/ -------------------------------------------------------------------------------- /ruby/.rspec: -------------------------------------------------------------------------------- 1 | --colour 2 | --format documentation 3 | -------------------------------------------------------------------------------- /scala/project/.gitignore: -------------------------------------------------------------------------------- 1 | project/ 2 | target/ 3 | -------------------------------------------------------------------------------- /scala/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.3.9 2 | -------------------------------------------------------------------------------- /COBOL/mf/src/.gitignore: -------------------------------------------------------------------------------- 1 | .cobolBuild 2 | /Gilded_Rose.bin/ 3 | -------------------------------------------------------------------------------- /Java/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'gilded-rose-kata' 2 | -------------------------------------------------------------------------------- /cpp/.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .vs 3 | cmake-build-debug 4 | build 5 | -------------------------------------------------------------------------------- /haskell/stack.yaml: -------------------------------------------------------------------------------- 1 | resolver: lts-12.14 2 | packages: 3 | - . 4 | -------------------------------------------------------------------------------- /haskell/test/Spec.hs: -------------------------------------------------------------------------------- 1 | {-# OPTIONS_GHC -F -pgmF hspec-discover #-} 2 | -------------------------------------------------------------------------------- /xslt/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | *.test_result.xml 3 | *.next_day.xml 4 | -------------------------------------------------------------------------------- /COBOL/mf/test/.gitignore: -------------------------------------------------------------------------------- 1 | /.cobolBuild 2 | /Coverage/ 3 | /Tests.bin/ 4 | -------------------------------------------------------------------------------- /cpp-catch2/test/ApprovalTests.hpp: -------------------------------------------------------------------------------- 1 | #include "ApprovalTests.v.10.0.0.hpp" -------------------------------------------------------------------------------- /python/.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | .cache 3 | .coverage 4 | .idea/ 5 | *.iml 6 | -------------------------------------------------------------------------------- /rust/Cargo.lock: -------------------------------------------------------------------------------- 1 | [root] 2 | name = "rust" 3 | version = "0.1.0" 4 | 5 | -------------------------------------------------------------------------------- /erlang/src/gilded_rose.app.src: -------------------------------------------------------------------------------- 1 | {application, gilded_rose, [{vsn, "0.1"}]}. 2 | -------------------------------------------------------------------------------- /erlang/rebar.config: -------------------------------------------------------------------------------- 1 | {erl_opts, [warnings_as_errors]}. 2 | {eunit_opts, [verbose]}. 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | bin 2 | obj 3 | *.sln.DotSettings.user 4 | .vs 5 | vendor 6 | .idea 7 | *.iml 8 | -------------------------------------------------------------------------------- /Ada/.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.ali 3 | b~*.ads 4 | b~*.adb 5 | program 6 | gilded_rose_tester 7 | -------------------------------------------------------------------------------- /swift/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | /.build 3 | /Packages 4 | /*.xcodeproj 5 | xcuserdata/ 6 | -------------------------------------------------------------------------------- /elixir/lib/item.ex: -------------------------------------------------------------------------------- 1 | defmodule Item do 2 | defstruct name: nil, sell_in: nil, quality: nil 3 | end 4 | -------------------------------------------------------------------------------- /elm/.gitignore: -------------------------------------------------------------------------------- 1 | elm-stuff 2 | # elm-repl generated files 3 | repl-temp-* 4 | *.src 5 | src/index.html 6 | -------------------------------------------------------------------------------- /erlang/rebar3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Leonidas-from-XIV/GildedRose-Refactoring-Kata/master/erlang/rebar3 -------------------------------------------------------------------------------- /php5/test/bootstrap.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /elm/src/Main.elm: -------------------------------------------------------------------------------- 1 | module Main exposing (main) 2 | 3 | import Html exposing (..) 4 | 5 | 6 | main = 7 | text "Gilded Rose" 8 | -------------------------------------------------------------------------------- /plantuml/gilded-rose.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Leonidas-from-XIV/GildedRose-Refactoring-Kata/master/plantuml/gilded-rose.png -------------------------------------------------------------------------------- /rust/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rust" 3 | version = "0.1.0" 4 | authors = ["Michael Gerhaeuser "] 5 | -------------------------------------------------------------------------------- /TypeScript/test/mocha.opts: -------------------------------------------------------------------------------- 1 | --compilers ts-node/register 2 | --require source-map-support/register 3 | --recursive 4 | test/**/*.spec.ts 5 | -------------------------------------------------------------------------------- /pascal/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | syntax: glob 3 | *.bak 4 | *.BAK 5 | *.tpu 6 | *.TPU 7 | *.exe 8 | *.EXE 9 | *.$$$ 10 | *.DSK 11 | *.TP 12 | -------------------------------------------------------------------------------- /cpp-catch2/test/main.cpp: -------------------------------------------------------------------------------- 1 | #define CATCH_CONFIG_MAIN 2 | #define APPROVALS_CATCH 3 | 4 | #include "catch2/catch.hpp" 5 | #include "ApprovalTests.hpp" -------------------------------------------------------------------------------- /erlang/include/gilded_rose.hrl: -------------------------------------------------------------------------------- 1 | -record(item, { 2 | name :: binary(), 3 | sell_in = 0 :: integer(), 4 | quality = 0 :: integer() 5 | }). 6 | -------------------------------------------------------------------------------- /texttests/ThirtyDays/._options.gr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Leonidas-from-XIV/GildedRose-Refactoring-Kata/master/texttests/ThirtyDays/._options.gr -------------------------------------------------------------------------------- /cpp/test/cpp_catch2_approvaltest/GildedRoseCatch2ApprovalTests.GildedRoseApprovalTests.approved.txt: -------------------------------------------------------------------------------- 1 | (Foo, 1, 1) => name: Foo, sellIn: 0, quality: 0 2 | 3 | -------------------------------------------------------------------------------- /elixir/test/gilded_rose_test.exs: -------------------------------------------------------------------------------- 1 | defmodule GildedRoseTest do 2 | use ExUnit.Case 3 | 4 | test "begin the journey of refactoring" do 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /scala/src/main/scala/com/gildedrose/Item.scala: -------------------------------------------------------------------------------- 1 | package com.gildedrose 2 | 3 | class Item(val name: String, var sellIn: Int, var quality: Int) { 4 | 5 | } -------------------------------------------------------------------------------- /Java/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Leonidas-from-XIV/GildedRose-Refactoring-Kata/master/Java/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /Kotlin/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Leonidas-from-XIV/GildedRose-Refactoring-Kata/master/Kotlin/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /cpp/lib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(LIB_NAME lib) 2 | add_library(${LIB_NAME} INTERFACE) 3 | target_include_directories(${LIB_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) -------------------------------------------------------------------------------- /elm/README.md: -------------------------------------------------------------------------------- 1 | # Gilded Rose (elm) 2 | 3 | To run tests, enter `elm-test` 4 | 5 | ### Installing `elm-test` 6 | 7 | https://github.com/elm-explorations/test 8 | -------------------------------------------------------------------------------- /plpgsql/pgtap/initialize.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -ex 4 | 5 | echo "Enable extension" 6 | psql -d kata -c 'CREATE EXTENSION IF NOT EXISTS pgtap;' 7 | -------------------------------------------------------------------------------- /dart/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: gilded_rose 2 | version: 0.0.1 3 | description: A simple console application. 4 | 5 | dev_dependencies: 6 | test: '>=0.12.11 <0.13.0' 7 | -------------------------------------------------------------------------------- /erlang/README.md: -------------------------------------------------------------------------------- 1 | # Erlang 2 | 3 | ## Prerequisites 4 | 5 | - Erlang/OTP 20 or later 6 | 7 | ## Running Tests 8 | 9 | ``` 10 | ./rebar3 eunit 11 | ``` 12 | -------------------------------------------------------------------------------- /haskell/.gitignore: -------------------------------------------------------------------------------- 1 | *.hi 2 | *.ho 3 | TAGS 4 | *.log 5 | *.profile 6 | /dist 7 | /cabal.config 8 | 9 | /.cabal-sandbox/ 10 | /cabal.sandbox.config 11 | 12 | -------------------------------------------------------------------------------- /plantuml/workshop-materials/testcases.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Leonidas-from-XIV/GildedRose-Refactoring-Kata/master/plantuml/workshop-materials/testcases.pdf -------------------------------------------------------------------------------- /plsql/run_tests.sql: -------------------------------------------------------------------------------- 1 | exec DBMS_SESSION.RESET_PACKAGE; 2 | set serveroutput on; 3 | exec DBMS_OUTPUT.ENABLE(1000000); 4 | 5 | exec ut.run(USER||':gilded_rose_tests'||''); -------------------------------------------------------------------------------- /Java-Spock/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Leonidas-from-XIV/GildedRose-Refactoring-Kata/master/Java-Spock/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /cpp/lib/ApprovalTests.hpp: -------------------------------------------------------------------------------- 1 | #ifndef APPROVAL_TEST_1_APPROVALTESTS_HPP 2 | #define APPROVAL_TEST_1_APPROVALTESTS_HPP 3 | #include "ApprovalTests.v.6.0.0.hpp" 4 | #endif 5 | -------------------------------------------------------------------------------- /swift/Tests/LinuxMain.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | 3 | import GildedRoseTests 4 | 5 | var tests = [XCTestCaseEntry]() 6 | tests += GildedRoseTests.allTests() 7 | XCTMain(tests) 8 | -------------------------------------------------------------------------------- /Java/.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | *.iml 3 | target/ 4 | 5 | .classpath 6 | .project 7 | bin/ 8 | .settings/ 9 | 10 | # Gradle 11 | .gradle 12 | /build/ 13 | 14 | -------------------------------------------------------------------------------- /cpp/test/cpp_googletest_approvaltest/GildedRoseGoogletestApprovalTests.GildedRoseApprovalTests.VerifyCombinations.approved.txt: -------------------------------------------------------------------------------- 1 | (Foo, 1, 1) => name: Foo, sellIn: 0, quality: 0 2 | 3 | -------------------------------------------------------------------------------- /dart/.gitignore: -------------------------------------------------------------------------------- 1 | # Files and directories created by pub 2 | .packages 3 | .pub/ 4 | packages 5 | pubspec.lock # (Remove this pattern if you wish to check in your lock file) 6 | .idea -------------------------------------------------------------------------------- /TypeScript/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .idea 3 | node_modules 4 | typings 5 | app/**/*.js 6 | app/**/*.js.map 7 | test/**/*.js 8 | test/**/*.js.map 9 | coverage 10 | .nyc_output 11 | -------------------------------------------------------------------------------- /php5/.settings/org.eclipse.php.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | include_path=0;/GildedRose.php/test\u00050;/GildedRose.php/src\u00055;org.eclipse.dltk.USER_LIBRARY/PEAR 3 | -------------------------------------------------------------------------------- /texttests/environment.gr: -------------------------------------------------------------------------------- 1 | # If your .class files are somewhere else, add the path to the list 2 | CLASSPATH:${TEXTTEST_HOME}/Java:${TEXTTEST_HOME}/Java/bin 3 | PERL5OPT:-I${TEXTTEST_HOME}/perl -------------------------------------------------------------------------------- /Java-Spock/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'groovy' 2 | 3 | repositories { 4 | mavenCentral() 5 | } 6 | 7 | dependencies { 8 | testCompile 'org.spockframework:spock-core:1.0-groovy-2.4' 9 | } 10 | -------------------------------------------------------------------------------- /c99/run-once-cmake.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [[ ! -d build ]]; then 4 | mkdir -p build 5 | fi 6 | 7 | cd build 8 | cmake .. -DCMAKE_BUILD_TYPE=DEBUG && cmake --build . && ctest --output-on-failure 9 | -------------------------------------------------------------------------------- /elixir/mix.exs: -------------------------------------------------------------------------------- 1 | defmodule GildedRose.Mixfile do 2 | use Mix.Project 3 | 4 | def project do 5 | [app: :gilded_rose, 6 | version: "0.0.1", 7 | elixir: "~> 1.0"] 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /cpp/test/cpp_googletest_approvaltest/googletest_approval_main.cc: -------------------------------------------------------------------------------- 1 | #define APPROVALS_GOOGLETEST // This tells Approval Tests to provide a main() - only do this in one cpp file 2 | #include "ApprovalTests.hpp" 3 | -------------------------------------------------------------------------------- /cpp/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(SRC_LIB_NAME src) 2 | add_library(${SRC_LIB_NAME}) 3 | target_sources(${SRC_LIB_NAME} PRIVATE GildedRose.cc) 4 | target_include_directories(${SRC_LIB_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) -------------------------------------------------------------------------------- /csharp/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /php7/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "require-dev": { 3 | "phpunit/phpunit": "^8.1" 4 | }, 5 | "autoload": { 6 | "psr-4": { 7 | "App\\": "src/" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /plpgsql/src/item.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE IF EXISTS item; 2 | CREATE TABLE item 3 | ( 4 | name character varying(100) NOT NULL, 5 | sell_in numeric(6) NOT NULL, 6 | quality numeric(6) NOT NULL 7 | ); 8 | 9 | -------------------------------------------------------------------------------- /ruby/.loadpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /C/README.txt: -------------------------------------------------------------------------------- 1 | run-once.sh runs your tests once 2 | 3 | Assumptions: 4 | - make and a C++ compiler (like gcc) is installed on your system and is in the PATH 5 | - The CppUTest framework is in the directory CppUTest 6 | -------------------------------------------------------------------------------- /R/runit_gilded_rose.R: -------------------------------------------------------------------------------- 1 | source('gilded_rose.R') 2 | 3 | test.foo <- function() { 4 | items <- list( item('foo', 0, 0) ) 5 | items <- update_quality(items) 6 | checkEquals('fixme', items[[1]]$name); 7 | } 8 | -------------------------------------------------------------------------------- /R/test_setup.R: -------------------------------------------------------------------------------- 1 | # A little helper script to get the testing infrastructure started 2 | 3 | # install.packages("RUnit") 4 | require(RUnit) 5 | 6 | # execute single test file 7 | runTestFile("runit_gilded_rose.R") 8 | -------------------------------------------------------------------------------- /plantuml/history/01_lower-both-values.puml: -------------------------------------------------------------------------------- 1 | @startuml 2 | 3 | skinparam backgroundColor transparent 4 | 5 | start 6 | 7 | :lower quality with 1; 8 | :lower sell in with 1; 9 | 10 | stop 11 | 12 | @enduml 13 | -------------------------------------------------------------------------------- /scala/build.sbt: -------------------------------------------------------------------------------- 1 | name := "GildedRose" 2 | 3 | version := "1.0" 4 | 5 | scalaVersion := "2.13.1" 6 | 7 | resolvers += DefaultMavenRepository 8 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.1.1" % "test" 9 | -------------------------------------------------------------------------------- /fsharp/GildedRose/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /ruby/.buildpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /cpp/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(cpp_catch2_approvaltest) 2 | add_subdirectory(cpp_catch2_unittest) 3 | add_subdirectory(cpp_googletest_approvaltest) 4 | add_subdirectory(cpp_googletest_unittest) 5 | add_subdirectory(cpp_texttest) 6 | -------------------------------------------------------------------------------- /csharpcore/Item.cs: -------------------------------------------------------------------------------- 1 | namespace csharpcore 2 | { 3 | public class Item 4 | { 5 | public string Name { get; set; } 6 | public int SellIn { get; set; } 7 | public int Quality { get; set; } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /perl6/lib/Item.pm6: -------------------------------------------------------------------------------- 1 | use v6; 2 | 3 | class Item { 4 | has Str $.name; 5 | has Int $.sell_in is rw = 0; 6 | has Int $.quality is rw = 0; 7 | 8 | method Str { 9 | "{$!name}, {$!sell_in}, {$!quality}" 10 | } 11 | }; 12 | -------------------------------------------------------------------------------- /plsql/create_user_if_needed.sql: -------------------------------------------------------------------------------- 1 | PROMPT Creating User 'DOJO' 2 | DROP USER dojo; 3 | CREATE USER dojo IDENTIFIED BY pass 4 | DEFAULT TABLESPACE USERS TEMPORARY TABLESPACE temp; 5 | GRANT RESOURCE TO dojo; 6 | GRANT CONNECT TO dojo; 7 | / 8 | -------------------------------------------------------------------------------- /sql/structure/postgreSQL/create.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE gilded_rose; 2 | 3 | \connect gilded_rose; 4 | 5 | CREATE TABLE item ( 6 | name CHARACTER VARYING(100) NOT NULL, 7 | sellIn INTEGER, 8 | quality INTEGER NOT NULL 9 | ); 10 | -------------------------------------------------------------------------------- /swift/Tests/GildedRoseTests/XCTestManifests.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | 3 | #if !canImport(ObjectiveC) 4 | public func allTests() -> [XCTestCaseEntry] { 5 | return [ 6 | testCase(GildedRoseTests.allTests), 7 | ] 8 | } 9 | #endif 10 | -------------------------------------------------------------------------------- /.bettercodehub.yml: -------------------------------------------------------------------------------- 1 | exclude: 2 | - /js/lib/.* 3 | component_depth: 1 4 | languages: 5 | - cpp 6 | - csharp 7 | - go 8 | - groovy 9 | - java 10 | - javascript 11 | - perl 12 | - php 13 | - python 14 | - ruby 15 | - scala 16 | - script 17 | - swift 18 | -------------------------------------------------------------------------------- /scala/.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | 3 | # OSX Finder 4 | .DS_Store 5 | 6 | # IntelliJ 7 | .idea 8 | *.iml 9 | 10 | # Eclipse 11 | .worksheet 12 | .settings 13 | .cache 14 | .cache-main 15 | .cache-tests 16 | .project 17 | .classpath 18 | 19 | target/ 20 | -------------------------------------------------------------------------------- /scheme/gilded-rose-test.scm: -------------------------------------------------------------------------------- 1 | (include "assert.scm") 2 | (include "gilded-rose.scm") 3 | 4 | (test-case "foo" 5 | (let ((items (list (make-item "foo" 0 0)))) 6 | (update-quality items) 7 | (assert-string= "fixme" (item-name (car items))))) 8 | -------------------------------------------------------------------------------- /C/GildedRose.h: -------------------------------------------------------------------------------- 1 | typedef struct 2 | { 3 | char *name; 4 | int sellIn; 5 | int quality; 6 | } Item; 7 | 8 | extern Item* init_item(Item* item, const char *name, int sellIn, int quality); 9 | extern void update_quality(Item items[], int size); 10 | -------------------------------------------------------------------------------- /Java/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /c99/GildedRose.h: -------------------------------------------------------------------------------- 1 | typedef struct 2 | { 3 | char *name; 4 | int sellIn; 5 | int quality; 6 | } Item; 7 | 8 | extern Item* init_item(Item* item, const char *name, int sellIn, int quality); 9 | extern void update_quality(Item items[], int size); 10 | -------------------------------------------------------------------------------- /Kotlin/src/main/kotlin/com/gildedrose/Item.kt: -------------------------------------------------------------------------------- 1 | package com.gildedrose 2 | 3 | open class Item(var name: String, var sellIn: Int, var quality: Int) { 4 | override fun toString(): String { 5 | return this.name + ", " + this.sellIn + ", " + this.quality 6 | } 7 | } -------------------------------------------------------------------------------- /js-jasmine/spec/support/jasmine.json: -------------------------------------------------------------------------------- 1 | { 2 | "spec_dir": "spec", 3 | "spec_files": [ 4 | "**/*[sS]pec.js" 5 | ], 6 | "helpers": [ 7 | "../node_modules/babel-register/lib/node.js" 8 | ], 9 | "oneFailurePerSpec": false, 10 | "randomizeTests": true 11 | } 12 | -------------------------------------------------------------------------------- /Ada/README.txt: -------------------------------------------------------------------------------- 1 | You will need the following programs: 2 | 3 | - GNU make (on Debian-like systems do 'apt-get install make') 4 | - gcc with Ada enabled ('apt-get install gnat') 5 | - the ahven unit-test framework ('apt-get install libahven5-dev') 6 | 7 | 'make test' runs your tests once. 8 | 9 | -------------------------------------------------------------------------------- /Ada/gilded_rose_tests.ads: -------------------------------------------------------------------------------- 1 | with Ahven.Framework; 2 | 3 | package Gilded_Rose_Tests is 4 | type Test is new Ahven.Framework.Test_Case with null record; 5 | 6 | procedure Initialize(T : in out Test); 7 | 8 | private 9 | 10 | procedure Test_Gilded_Rose; 11 | end Gilded_Rose_Tests; 12 | -------------------------------------------------------------------------------- /Kotlin/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Nov 20 10:18:48 CET 2019 2 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.8.1-all.zip 3 | distributionBase=GRADLE_USER_HOME 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /plsql/new_item.sql: -------------------------------------------------------------------------------- 1 | CREATE OR REPLACE PROCEDURE new_item( 2 | i_name item.name%TYPE, 3 | i_sell_in item.sell_in%TYPE, 4 | i_quality item.quality%TYPE) 5 | IS 6 | BEGIN 7 | INSERT INTO item (name, sell_in, quality) VALUES (i_name, i_sell_in, i_quality); 8 | END new_item; 9 | / 10 | -------------------------------------------------------------------------------- /plsql/texttest.pks: -------------------------------------------------------------------------------- 1 | CREATE OR REPLACE PACKAGE texttest IS 2 | -- %suite(texttest) 3 | -- %suitepath(gilded_rose_tests) 4 | -- %rollback(manual) 5 | 6 | -- %beforeall 7 | PROCEDURE setup; 8 | 9 | -- %test(main test) 10 | PROCEDURE main_test; 11 | END texttest; 12 | / -------------------------------------------------------------------------------- /Groovy/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Java-Spock/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Jul 05 09:24:35 CEST 2016 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.9-bin.zip 7 | -------------------------------------------------------------------------------- /TypeScript/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "target": "es5", 5 | "strict": true, 6 | "noImplicitAny": false, 7 | "sourceMap": false 8 | }, 9 | "exclude": [ 10 | "node_modules" 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /rust/src/gildedrose/test.rs: -------------------------------------------------------------------------------- 1 | use super::{Item, GildedRose}; 2 | 3 | #[test] 4 | pub fn foo() { 5 | let items = vec![Item::new(String::from("foo"), 0, 0)]; 6 | let mut rose = GildedRose::new(items); 7 | rose.update_quality(); 8 | 9 | assert_eq!("fixme", rose.items[0].name); 10 | } 11 | -------------------------------------------------------------------------------- /plantuml/history/02_sell-by-passed.puml: -------------------------------------------------------------------------------- 1 | @startuml 2 | 3 | skinparam backgroundColor transparent 4 | 5 | start 6 | 7 | :lower quality with 1; 8 | :lower sell in with 1; 9 | 10 | if (sell in < 0) then (yes) 11 | :lower quality with 1; 12 | else (no) 13 | endif 14 | 15 | stop 16 | 17 | @enduml 18 | -------------------------------------------------------------------------------- /xslt/gilded_rose.dtd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | -------------------------------------------------------------------------------- /php5/.buildpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /fsharp/GildedRose.Tests/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /go/README.md: -------------------------------------------------------------------------------- 1 | # GO Starter 2 | 3 | - Run : 4 | 5 | ```shell 6 | go run texttest_fixture.go gilded-rose.go 7 | ``` 8 | 9 | - Run tests : 10 | 11 | ```shell 12 | go test 13 | ``` 14 | 15 | - Run tests and coverage : 16 | 17 | ```shell 18 | go test -coverprofile=coverage.out 19 | 20 | go tool cover -html=coverage.out 21 | ``` -------------------------------------------------------------------------------- /go/gilded-rose_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "testing" 4 | 5 | func Test_Foo(t *testing.T) { 6 | var items = []*Item{ 7 | &Item{"foo", 0, 0}, 8 | } 9 | 10 | UpdateQuality(items) 11 | 12 | if items[0].name != "fixme" { 13 | t.Errorf("Name: Expected %s but got %s ", "fixme", items[0].name) 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /perl/Item.pm: -------------------------------------------------------------------------------- 1 | package Item; 2 | 3 | use strict; 4 | use warnings; 5 | 6 | sub new { 7 | my ( $class, %attrs ) = @_; 8 | return bless \%attrs, $class; 9 | } 10 | 11 | sub to_string { 12 | my ($self) = @_; 13 | return $self->{name} . ', ' . $self->{sell_in} . ', ' . $self->{quality}; 14 | } 15 | 16 | 1; 17 | -------------------------------------------------------------------------------- /perl6/test.p6: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl6 2 | 3 | use v6; 4 | use Test; 5 | use lib 'lib'; 6 | 7 | use GildedRose; 8 | use Item; 9 | 10 | my $item = Item.new(:name); 11 | my $app = GildedRose.new(items => ($item)); 12 | 13 | $app.update_quality(); 14 | is $app.items[0].name, 'fixme', "first day pass"; 15 | 16 | done-testing; 17 | -------------------------------------------------------------------------------- /php5/.settings/org.eclipse.wst.common.project.facet.core.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /plpgsql/initializeDatabase.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -ex 4 | 5 | echo "Create database" 6 | psql -d postgres -c 'DROP DATABASE IF EXISTS kata;' 7 | psql -d postgres -c 'CREATE DATABASE kata;' 8 | 9 | ./initialize.sh 10 | 11 | echo "Add current code" 12 | psql -d kata -f src/item.sql 13 | psql -d kata -f src/new_item.sql 14 | -------------------------------------------------------------------------------- /ruby/gilded_rose_tests.rb: -------------------------------------------------------------------------------- 1 | require File.join(File.dirname(__FILE__), 'gilded_rose') 2 | require 'test/unit' 3 | 4 | class TestUntitled < Test::Unit::TestCase 5 | 6 | def test_foo 7 | items = [Item.new("foo", 0, 0)] 8 | GildedRose.new(items).update_quality() 9 | assert_equal items[0].name, "fixme" 10 | end 11 | 12 | end -------------------------------------------------------------------------------- /Ada/items.ads: -------------------------------------------------------------------------------- 1 | with Ada.Strings.Unbounded; 2 | 3 | package Items is 4 | package SU renames Ada.Strings.Unbounded; 5 | 6 | type Item is record 7 | Name : SU.Unbounded_String; 8 | Sell_In : Integer; 9 | Quality : Integer; 10 | end record; 11 | 12 | function To_String(Self : in Item) return String; 13 | 14 | end Items; 15 | -------------------------------------------------------------------------------- /cpp/test/cpp_googletest_unittest/GildedRoseGoogletestUnitTests.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include "GildedRose.h" 3 | 4 | TEST(GildedRoseTest, Foo) { 5 | vector items; 6 | items.push_back(Item("Foo", 0, 0)); 7 | GildedRose app(items); 8 | app.updateQuality(); 9 | EXPECT_EQ("fixme", app.items[0].name); 10 | } 11 | -------------------------------------------------------------------------------- /js-jest/test/gilded_rose.test.js: -------------------------------------------------------------------------------- 1 | const {Shop, Item} = require("../src/gilded_rose"); 2 | 3 | describe("Gilded Rose", function() { 4 | it("should foo", function() { 5 | const gildedRose = new Shop([new Item("foo", 0, 0)]); 6 | const items = gildedRose.updateQuality(); 7 | expect(items[0].name).toBe("fixme"); 8 | }); 9 | }); 10 | -------------------------------------------------------------------------------- /plpgsql/src/new_item.sql: -------------------------------------------------------------------------------- 1 | DROP PROCEDURE IF EXISTS new_item; 2 | CREATE PROCEDURE new_item( 3 | name item.name%TYPE, 4 | sell_in item.sell_in%TYPE, 5 | quality item.quality%TYPE 6 | ) 7 | LANGUAGE plpgsql 8 | AS $$ 9 | BEGIN 10 | INSERT INTO item (name, sell_in, quality) VALUES (name, sell_in, quality); 11 | END; 12 | $$; 13 | -------------------------------------------------------------------------------- /plsql/ut_update_quality.pks: -------------------------------------------------------------------------------- 1 | CREATE OR REPLACE PACKAGE ut_update_quality 2 | IS 3 | -- %suite(UT_REGRESSION_TEST) 4 | -- %suitepath(gilded_rose_tests) 5 | -- %rollback(manual) 6 | 7 | -- %beforeeach 8 | PROCEDURE cleanup_before_each; 9 | 10 | -- %test(Foo test) 11 | PROCEDURE ut_foo; 12 | END ut_update_quality; 13 | / 14 | -------------------------------------------------------------------------------- /php5/.settings/com.piece_framework.makegood.core.prefs: -------------------------------------------------------------------------------- 1 | cakephp_app_path= 2 | cakephp_core_path= 3 | ciunit_config_file= 4 | ciunit_path= 5 | eclipse.preferences.version=1 6 | phpunit_config_file=/GildedRose.php/phpunit.xml 7 | preload_script= 8 | test_file_pattern=.*test\\.php$ 9 | test_folders=/GildedRose.php/test 10 | testing_framework=PHPUnit 11 | -------------------------------------------------------------------------------- /Ada/gilded_rose_tester.adb: -------------------------------------------------------------------------------- 1 | with Ahven.Text_Runner; 2 | with Ahven.Framework; 3 | with Gilded_Rose_Tests; 4 | 5 | procedure Gilded_Rose_Tester is 6 | S : Ahven.Framework.Test_Suite := Ahven.Framework.Create_Suite("All"); 7 | begin 8 | Ahven.Framework.Add_Test(S, new Gilded_Rose_Tests.Test); 9 | Ahven.Text_Runner.Run(S); 10 | end Gilded_Rose_Tester; 11 | -------------------------------------------------------------------------------- /js-jasmine/spec/gilded_rose_spec.js: -------------------------------------------------------------------------------- 1 | var {Shop, Item} = require('../src/gilded_rose.js'); 2 | describe("Gilded Rose", function() { 3 | 4 | it("should foo", function() { 5 | const gildedRose = new Shop([ new Item("foo", 0, 0) ]); 6 | const items = gildedRose.updateQuality(); 7 | expect(items[0].name).toEqual("fixme"); 8 | }); 9 | 10 | }); 11 | -------------------------------------------------------------------------------- /ruby/gilded_rose_spec.rb: -------------------------------------------------------------------------------- 1 | require File.join(File.dirname(__FILE__), 'gilded_rose') 2 | 3 | describe GildedRose do 4 | 5 | describe "#update_quality" do 6 | it "does not change the name" do 7 | items = [Item.new("foo", 0, 0)] 8 | GildedRose.new(items).update_quality() 9 | expect(items[0].name).to eq "fixme" 10 | end 11 | end 12 | 13 | end 14 | -------------------------------------------------------------------------------- /dart/test/gilded_rose_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:test/test.dart'; 2 | import 'package:gilded_rose/gilded_rose.dart'; 3 | 4 | main() { 5 | test('foo', () { 6 | var item = new Item('foo', 0, 0); 7 | var items = [item]; 8 | 9 | GildedRose app = new GildedRose(items); 10 | app.updateQuality(); 11 | expect("fixme", app.items[0].name); 12 | }); 13 | } 14 | -------------------------------------------------------------------------------- /haskell/test/GildedRoseSpec.hs: -------------------------------------------------------------------------------- 1 | module GildedRoseSpec (spec) where 2 | 3 | import Test.Hspec 4 | import GildedRose 5 | 6 | spec :: Spec 7 | spec = 8 | describe "updateQuality" $ do 9 | 10 | it "fixme" $ 11 | let inventory = [Item "foo" 0 0] 12 | actual = updateQuality inventory 13 | expected = [] 14 | in actual `shouldBe` expected 15 | -------------------------------------------------------------------------------- /php7/test/GildedRoseTest.php: -------------------------------------------------------------------------------- 1 | updateQuality(); 10 | $this->assertEquals("fixme", $items[0]->name); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /csharp/Item.cs: -------------------------------------------------------------------------------- 1 | namespace csharp 2 | { 3 | public class Item 4 | { 5 | public string Name { get; set; } 6 | public int SellIn { get; set; } 7 | public int Quality { get; set; } 8 | 9 | public override string ToString() 10 | { 11 | return this.Name + ", " + this.SellIn + ", " + this.Quality; 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /csharp/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /js-mocha/test/test_gilded_rose.js: -------------------------------------------------------------------------------- 1 | var {expect} = require('chai'); 2 | var {Shop, Item} = require('../src/gilded_rose.js'); 3 | describe("Gilded Rose", function() { 4 | 5 | it("should foo", function() { 6 | const gildedRose = new Shop([ new Item("foo", 0, 0) ]); 7 | const items = gildedRose.updateQuality(); 8 | expect(items[0].name).to.equal("fixme"); 9 | }); 10 | 11 | }); 12 | -------------------------------------------------------------------------------- /R/item.R: -------------------------------------------------------------------------------- 1 | item <- function(name, sell_in, quality) { 2 | newItem <- list(name=name, sell_in=sell_in, quality=quality) 3 | class(newItem) <- 'item' 4 | newItem 5 | } 6 | 7 | as.character.item <- function(item) { 8 | paste(item$name, ", ", item$sell_in, ", ", item$quality, sep='') 9 | } 10 | 11 | print.item <- function(item) { 12 | print.default(as.character(item)) 13 | } 14 | -------------------------------------------------------------------------------- /Groovy/src/com/gildedrose/GildedRoseTest.groovy: -------------------------------------------------------------------------------- 1 | package com.gildedrose 2 | 3 | import org.junit.Test 4 | 5 | class GildedRoseTest { 6 | 7 | @Test 8 | void "foo"() { 9 | def items = [ new Item("foo", 0, 0) ] as Item[] 10 | def app = new GildedRose(items) 11 | app.updateQuality() 12 | assert "fixme" == app.items[0].name 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /php5/test/gilded_rose_test.php: -------------------------------------------------------------------------------- 1 | update_quality(); 11 | $this->assertEquals("fixme", $items[0]->name); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /plsql/item.sql: -------------------------------------------------------------------------------- 1 | PROMPT Creating Table 'ITEM' 2 | 3 | BEGIN 4 | EXECUTE IMMEDIATE 'DROP TABLE item'; 5 | EXCEPTION 6 | WHEN OTHERS THEN 7 | IF SQLCODE != -942 THEN 8 | RAISE; 9 | END IF; 10 | END; 11 | 12 | CREATE TABLE item 13 | ( 14 | name VARCHAR2(100) NOT NULL, 15 | sell_in NUMBER(6) NOT NULL, 16 | quality NUMBER(6) NOT NULL 17 | ); 18 | / 19 | 20 | SHOW ERRORS; 21 | -------------------------------------------------------------------------------- /Ada/gilded_rose.ads: -------------------------------------------------------------------------------- 1 | with Ada.Containers.Vectors; 2 | with Items; 3 | use Items; 4 | 5 | package Gilded_Rose is 6 | package Item_Vecs is new Ada.Containers.Vectors ( 7 | Element_Type => Item, 8 | Index_Type => Positive 9 | ); 10 | 11 | type Gilded_Rose is record 12 | Items : Item_Vecs.Vector; 13 | end record; 14 | procedure Update_Quality(Self : in out Gilded_Rose); 15 | end Gilded_Rose; 16 | -------------------------------------------------------------------------------- /c99/test_unity_gildedrose.c: -------------------------------------------------------------------------------- 1 | #include "unity.h" 2 | #include "GildedRose.h" 3 | 4 | void test_NameOfItem(void) 5 | { 6 | Item items[1]; 7 | init_item(items, "Foo", 0, 0); 8 | update_quality(items, 1); 9 | TEST_ASSERT_EQUAL_STRING( "fixme", items[0].name ); 10 | } 11 | 12 | int main(void) 13 | { 14 | UNITY_BEGIN(); 15 | RUN_TEST(test_NameOfItem); 16 | return UNITY_END(); 17 | } 18 | 19 | -------------------------------------------------------------------------------- /TypeScript/test/gilded-rose.spec.ts: -------------------------------------------------------------------------------- 1 | import { expect } from 'chai'; 2 | import { Item, GildedRose } from '../app/gilded-rose'; 3 | 4 | describe('Gilded Rose', function () { 5 | 6 | it('should foo', function() { 7 | const gildedRose = new GildedRose([ new Item('foo', 0, 0) ]); 8 | const items = gildedRose.updateQuality(); 9 | expect(items[0].name).to.equal('fixme'); 10 | }); 11 | 12 | }); 13 | -------------------------------------------------------------------------------- /fsharp-core/GildedRose.UnitTests/Tests.fs: -------------------------------------------------------------------------------- 1 | module GildedRose.UnitTests 2 | 3 | open GildedRose 4 | open System.Collections.Generic 5 | open Xunit 6 | open Swensen.Unquote 7 | 8 | [] 9 | let ``My test`` () = 10 | let Items = new List() 11 | Items.Add({Name = "foo"; SellIn = 0; Quality = 0}) 12 | let app = new GildedRose(Items) 13 | app.UpdateQuality() 14 | test <@ "fixme" = Items.[0].Name @> -------------------------------------------------------------------------------- /Kotlin/src/test/kotlin/com/gildedrose/GildedRoseTest.kt: -------------------------------------------------------------------------------- 1 | package com.gildedrose 2 | 3 | import org.junit.Assert.* 4 | import org.junit.Test 5 | 6 | class GildedRoseTest { 7 | 8 | @Test fun foo() { 9 | val items = arrayOf(Item("foo", 0, 0)) 10 | val app = GildedRose(items) 11 | app.updateQuality() 12 | assertEquals("fixme", app.items[0].name) 13 | 14 | } 15 | 16 | 17 | } 18 | 19 | 20 | -------------------------------------------------------------------------------- /fsharp-core/GildedRose/GildedRose.fsproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /perl/test.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use Test::More 0.96; 7 | 8 | use_ok 'GildedRose'; 9 | use_ok 'Item'; 10 | 11 | subtest 'foo' => sub { 12 | my $items = [ Item->new( name => 'foo', sell_in => 0, quality => 0 ) ]; 13 | my $app = GildedRose->new( items => $items ); 14 | $app->update_quality(); 15 | is( $app->{items}->[0]->{name}, 'fixme' ); 16 | }; 17 | 18 | done_testing(); 19 | -------------------------------------------------------------------------------- /plpgsql/pgunit/initialize.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -ex 4 | 5 | echo "Enable DBLINK" 6 | psql -d kata -c 'CREATE EXTENSION DBLINK;' 7 | 8 | echo "Initialize test framework" 9 | wget https://raw.githubusercontent.com/adrianandrei-ca/pgunit/bc69dfc526ec3db55ff72af5d78eab55661502af/PGUnit.sql \ 10 | && psql -d kata -f PGUnit.sql \ 11 | && rm PGUnit.sql 12 | 13 | echo "Initialize custom asserts" 14 | psql -d kata -f asserts.sql 15 | -------------------------------------------------------------------------------- /python/test_gilded_rose.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import unittest 3 | 4 | from gilded_rose import Item, GildedRose 5 | 6 | class GildedRoseTest(unittest.TestCase): 7 | def test_foo(self): 8 | items = [Item("foo", 0, 0)] 9 | gilded_rose = GildedRose(items) 10 | gilded_rose.update_quality() 11 | self.assertEquals("fixme", items[0].name) 12 | 13 | if __name__ == '__main__': 14 | unittest.main() 15 | -------------------------------------------------------------------------------- /sql/README.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | This code aims to be based on ISO-compliant, therefore database-agnostic. 3 | However, Data Definition Language (DDL) usually involves vendor variants. 4 | 5 | # Setup 6 | Create database structure: see ./structure//create.sql 7 | Load test data: see ./test/data/load.sql 8 | 9 | # Execution 10 | Execute SQL script: see /code/update_quality.sql 11 | TODO: Introduce test framework - vendor specific 12 | 13 | -------------------------------------------------------------------------------- /cpp/test/cpp_catch2_unittest/GildedRoseCatch2UnitTests.cc: -------------------------------------------------------------------------------- 1 | #define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file 2 | #include "Catch.hpp" 3 | #include "GildedRose.h" 4 | 5 | TEST_CASE("GildedRoseUnitTest", "Foo") 6 | { 7 | vector items; 8 | items.push_back(Item("Foo", 0, 0)); 9 | GildedRose app(items); 10 | app.updateQuality(); 11 | REQUIRE("fixme" == app.items[0].name); 12 | } 13 | -------------------------------------------------------------------------------- /plantuml/history/03_quality-never-negative.puml: -------------------------------------------------------------------------------- 1 | @startuml 2 | 3 | skinparam backgroundColor transparent 4 | 5 | start 6 | 7 | if (quality > 0) then (yes) 8 | :lower quality with 1; 9 | else (no) 10 | endif 11 | 12 | :lower sell in with 1; 13 | 14 | if (sell in < 0) then (yes) 15 | if (quality > 0) then (yes) 16 | :lower quality with 1; 17 | else (no) 18 | endif 19 | else (no) 20 | endif 21 | 22 | stop 23 | 24 | @enduml 25 | -------------------------------------------------------------------------------- /scheme/README.md: -------------------------------------------------------------------------------- 1 | # Scheme port of the Gilded-Rose Kata 2 | 3 | This is a (Gambit) R5RS Scheme port of the *Gilded-Rose-Kata*. 4 | 5 | ## Building and Running 6 | 7 | ```shell 8 | gsi texttest-fixture.scm 9 | ``` 10 | 11 | ## Unit Test 12 | 13 | `assert.scm` is a minimalist implementation of xUnit in Scheme style. 14 | There are two assertions available, e.g. `(assert=)` and `(assert-string=)`. 15 | 16 | ```shell 17 | gsi gilded-rose-test.scm 18 | ``` 19 | -------------------------------------------------------------------------------- /d/dub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "GildedRose", 3 | "configurations": [ 4 | { 5 | "name": "GuildedRose", 6 | "targetType": "executable", 7 | "mainSourceFile": "src/GildedRoseTextTests.d" 8 | }, 9 | { 10 | "name": "unittest", 11 | "targetType": "executable", 12 | "sourcePaths": ["test"], 13 | "mainSourceFile": "test/GildedRoseUnitTests.d" 14 | } 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /js-jest/README.md: -------------------------------------------------------------------------------- 1 | # Gilded Rose 2 | 3 | This is the Gilded Rose kata in JavaScript with Jest 4 | 5 | ## Getting started 6 | 7 | Install dependencies 8 | 9 | ```sh 10 | npm install 11 | ``` 12 | 13 | ## Running tests 14 | 15 | To run all tests 16 | 17 | ```sh 18 | npm test 19 | ``` 20 | 21 | To run all tests in watch mode 22 | 23 | ```sh 24 | npm run test:watch 25 | ``` 26 | 27 | To generate test coverage report 28 | 29 | ```sh 30 | npm run test:coverage 31 | ``` 32 | -------------------------------------------------------------------------------- /scala/src/test/scala/com/gildedrose/GildedRoseTest.scala: -------------------------------------------------------------------------------- 1 | package com.gildedrose 2 | 3 | import org.scalatest.flatspec.AnyFlatSpec 4 | import org.scalatest.matchers.should.Matchers 5 | 6 | class GildedRoseTest extends AnyFlatSpec with Matchers { 7 | it should "foo" in { 8 | val items = Array[Item](new Item("foo", 0, 0)) 9 | val app = new GildedRose(items) 10 | app.updateQuality() 11 | app.items(0).name should equal ("fixme") 12 | } 13 | } -------------------------------------------------------------------------------- /COBOL/mf/src/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | Gilded Rose 4 | 5 | 6 | 7 | 8 | 9 | com.microfocus.eclipse.project.cobolBuilder 10 | 11 | 12 | 13 | 14 | 15 | com.microfocus.eclipse.project.cobolNature 16 | 17 | 18 | -------------------------------------------------------------------------------- /cpp/src/GildedRose.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | class Item 7 | { 8 | public: 9 | string name; 10 | int sellIn; 11 | int quality; 12 | Item(string name, int sellIn, int quality) : name(name), sellIn(sellIn), quality(quality) 13 | {} 14 | }; 15 | 16 | class GildedRose 17 | { 18 | public: 19 | vector & items; 20 | GildedRose(vector & items); 21 | 22 | void updateQuality(); 23 | }; 24 | 25 | -------------------------------------------------------------------------------- /php7/src/Item.php: -------------------------------------------------------------------------------- 1 | name = $name; 13 | $this->sell_in = $sell_in; 14 | $this->quality = $quality; 15 | } 16 | 17 | public function __toString() { 18 | return "{$this->name}, {$this->sell_in}, {$this->quality}"; 19 | } 20 | } 21 | 22 | -------------------------------------------------------------------------------- /Groovy/src/com/gildedrose/Item.groovy: -------------------------------------------------------------------------------- 1 | package com.gildedrose 2 | 3 | class Item { 4 | 5 | String name 6 | 7 | int sellIn 8 | 9 | int quality 10 | 11 | Item(String name, int sellIn, int quality) { 12 | this.name = name 13 | this.sellIn = sellIn 14 | this.quality = quality 15 | } 16 | 17 | @Override 18 | String toString() { 19 | return this.name + ", " + this.sellIn + ", " + this.quality 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /elm/tests/GildedRoseTest.elm: -------------------------------------------------------------------------------- 1 | module GildedRoseTest exposing (..) 2 | 3 | import Expect exposing (Expectation) 4 | import Fuzz exposing (Fuzzer, int, list, string) 5 | import GildedRose exposing (..) 6 | import Test exposing (..) 7 | 8 | 9 | suite : Test 10 | suite = 11 | test "example test" 12 | (\_ -> 13 | let 14 | foo = 15 | Item "foo" 10 30 16 | in 17 | Expect.equal foo.name "fixme" 18 | ) 19 | -------------------------------------------------------------------------------- /Java/src/test/java/com/gildedrose/GildedRoseTest.java: -------------------------------------------------------------------------------- 1 | package com.gildedrose; 2 | 3 | import org.junit.jupiter.api.Test; 4 | 5 | import static org.junit.jupiter.api.Assertions.assertEquals; 6 | 7 | class GildedRoseTest { 8 | 9 | @Test 10 | void foo() { 11 | Item[] items = new Item[] { new Item("foo", 0, 0) }; 12 | GildedRose app = new GildedRose(items); 13 | app.updateQuality(); 14 | assertEquals("fixme", app.items[0].name); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /cpp-catch2/src/GildedRose.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | class Item 7 | { 8 | public: 9 | string name; 10 | int sellIn; 11 | int quality; 12 | Item(string name, int sellIn, int quality) : name(name), sellIn(sellIn), quality(quality) 13 | {} 14 | }; 15 | 16 | class GildedRose 17 | { 18 | public: 19 | vector & items; 20 | GildedRose(vector & items); 21 | 22 | void updateQuality(); 23 | }; 24 | 25 | -------------------------------------------------------------------------------- /php5/phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | test 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /plpgsql/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.4' 2 | 3 | services: 4 | pgunit: 5 | # image: fpellet/gildedrose-refactoring-kata:pgunit 6 | build: 7 | context: . 8 | target: pgunit 9 | ports: 10 | - "5432:5432" 11 | volumes: 12 | - .:/app/:z 13 | 14 | pgtap: 15 | # image: fpellet/gildedrose-refactoring-kata:pgtap 16 | build: 17 | context: . 18 | target: pgtap 19 | ports: 20 | - "5432:5432" 21 | volumes: 22 | - .:/app/:z 23 | -------------------------------------------------------------------------------- /plpgsql/pgtap/test_case_update_quality.sql: -------------------------------------------------------------------------------- 1 | BEGIN; 2 | -- Plan count should match the number of tests. If it does not then pg_prove will fail the test 3 | SELECT plan(1); 4 | 5 | -- Run the tests. 6 | -- Given 7 | TRUNCATE TABLE item; 8 | CALL new_item('foo', 0, 0); 9 | 10 | -- When 11 | CALL update_quality(); 12 | 13 | -- Then 14 | SELECT is( name, 'fixme', 'name did change' ) FROM item; 15 | 16 | -- Finish the tests and clean up. 17 | SELECT * FROM finish(); 18 | ROLLBACK; 19 | -------------------------------------------------------------------------------- /plsql/ut_update_quality.pkb: -------------------------------------------------------------------------------- 1 | CREATE OR REPLACE PACKAGE BODY ut_update_quality IS 2 | PROCEDURE cleanup_before_each IS 3 | BEGIN 4 | DELETE FROM item; 5 | END; 6 | 7 | PROCEDURE ut_foo IS 8 | l_name item.name%TYPE; 9 | BEGIN 10 | new_item('foo', 0, 0); 11 | 12 | update_quality(); 13 | 14 | SELECT name INTO l_name FROM item; 15 | 16 | ut.expect(l_name, a_message => 'name did change').to_equal('fixme'); 17 | END ut_foo; 18 | END ut_update_quality; 19 | / -------------------------------------------------------------------------------- /csharpcore/GildedRoseTest.cs: -------------------------------------------------------------------------------- 1 | using Xunit; 2 | using System.Collections.Generic; 3 | 4 | namespace csharpcore 5 | { 6 | public class GildedRoseTest 7 | { 8 | [Fact] 9 | public void foo() 10 | { 11 | IList Items = new List { new Item { Name = "foo", SellIn = 0, Quality = 0 } }; 12 | GildedRose app = new GildedRose(Items); 13 | app.UpdateQuality(); 14 | Assert.Equal("fixme", Items[0].Name); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /Java/src/main/java/com/gildedrose/Item.java: -------------------------------------------------------------------------------- 1 | package com.gildedrose; 2 | 3 | public class Item { 4 | 5 | public String name; 6 | 7 | public int sellIn; 8 | 9 | public int quality; 10 | 11 | public Item(String name, int sellIn, int quality) { 12 | this.name = name; 13 | this.sellIn = sellIn; 14 | this.quality = quality; 15 | } 16 | 17 | @Override 18 | public String toString() { 19 | return this.name + ", " + this.sellIn + ", " + this.quality; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /plpgsql/initializeDocker.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | wait_database() 4 | { 5 | while : 6 | do 7 | (echo > /dev/tcp/127.0.0.1/5432) >/dev/null 2>&1 8 | result=$? 9 | 10 | if [[ $result -eq 0 ]]; then 11 | break 12 | fi 13 | sleep 1 14 | done 15 | return $result 16 | } 17 | 18 | nohup docker-entrypoint.sh postgres > /dev/null 2>&1 & 19 | wait_database 20 | 21 | set -ex 22 | 23 | ./initializeDatabase.sh 24 | 25 | echo "Stop database" 26 | disown %1 27 | -------------------------------------------------------------------------------- /Java-Spock/src/main/java/com/gildedrose/Item.java: -------------------------------------------------------------------------------- 1 | package com.gildedrose; 2 | 3 | public class Item { 4 | 5 | public String name; 6 | 7 | public int sellIn; 8 | 9 | public int quality; 10 | 11 | public Item(String name, int sellIn, int quality) { 12 | this.name = name; 13 | this.sellIn = sellIn; 14 | this.quality = quality; 15 | } 16 | 17 | @Override 18 | public String toString() { 19 | return this.name + ", " + this.sellIn + ", " + this.quality; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /R/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | GildedRose.R 4 | 5 | 6 | 7 | 8 | 9 | de.walware.statet.r.builders.RSupport 10 | 11 | 12 | 13 | 14 | 15 | de.walware.statet.base.StatetNature 16 | de.walware.statet.r.RNature 17 | 18 | 19 | -------------------------------------------------------------------------------- /Delphi/.gitattributes: -------------------------------------------------------------------------------- 1 | # Set the default behavior, in case people don't have core.autocrlf set. 2 | * text=auto 3 | 4 | # Explicitly declare text files you want to always be normalized and converted 5 | # to native line endings on checkout. 6 | *.groupproj text 7 | *.dpr text 8 | *.dproj text 9 | *.pas text 10 | *.dfm text 11 | *.fmx text 12 | 13 | # Declare files that will always have CRLF line endings on checkout. 14 | 15 | # Denote all files that are truly binary and should not be modified. 16 | *.exe binary 17 | *.res binary 18 | -------------------------------------------------------------------------------- /csharp/GildedRoseTest.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | using System.Collections.Generic; 3 | 4 | namespace csharp 5 | { 6 | [TestFixture] 7 | public class GildedRoseTest 8 | { 9 | [Test] 10 | public void foo() 11 | { 12 | IList Items = new List { new Item { Name = "foo", SellIn = 0, Quality = 0 } }; 13 | GildedRose app = new GildedRose(Items); 14 | app.UpdateQuality(); 15 | Assert.AreEqual("fixme", Items[0].Name); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /swift/Sources/GildedRose/Item.swift: -------------------------------------------------------------------------------- 1 | public class Item { 2 | public var name: String 3 | public var sellIn: Int 4 | public var quality: Int 5 | 6 | public init(name: String, sellIn: Int, quality: Int) { 7 | self.name = name 8 | self.sellIn = sellIn 9 | self.quality = quality 10 | } 11 | } 12 | 13 | extension Item: CustomStringConvertible { 14 | public var description: String { 15 | return self.name + ", " + String(self.sellIn) + ", " + String(self.quality); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /php7/phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | test 11 | 12 | 13 | 14 | 15 | 16 | src 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /Groovy/Groovy.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /swift/Tests/GildedRoseTests/GildedRoseTests.swift: -------------------------------------------------------------------------------- 1 | @testable import GildedRose 2 | import XCTest 3 | 4 | class GildedRoseTests: XCTestCase { 5 | 6 | func testFoo() { 7 | let items = [Item(name: "foo", sellIn: 0, quality: 0)] 8 | let app = GildedRose(items: items); 9 | app.updateQuality(); 10 | XCTAssertEqual("fixme", app.items[0].name); 11 | } 12 | 13 | static var allTests : [(String, (GildedRoseTests) -> () throws -> Void)] { 14 | return [ 15 | ("testFoo", testFoo), 16 | ] 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Java/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java' 3 | } 4 | 5 | repositories { 6 | mavenCentral() 7 | } 8 | 9 | dependencies { 10 | testImplementation 'org.junit.jupiter:junit-jupiter-api:5.6.2' 11 | testImplementation 'org.junit.jupiter:junit-jupiter-params:5.6.2' 12 | testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.6.2' 13 | testImplementation 'com.approvaltests:approvaltests:5.0.0' 14 | } 15 | 16 | group = 'com.gildedrose' 17 | version = '0.0.1-SNAPSHOT' 18 | sourceCompatibility = '1.8' 19 | 20 | test { 21 | useJUnitPlatform() 22 | } 23 | -------------------------------------------------------------------------------- /Kotlin/.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | out/ 3 | *.class 4 | 5 | *.iml 6 | 7 | # Created by https://www.gitignore.io/api/gradle 8 | 9 | ### Gradle ### 10 | .gradle 11 | **/build/ 12 | 13 | # Ignore Gradle GUI config 14 | gradle-app.setting 15 | 16 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) 17 | !gradle-wrapper.jar 18 | 19 | # Cache of project 20 | .gradletasknamecache 21 | 22 | # # Work around https://youtrack.jetbrains.com/issue/IDEA-116898 23 | # gradle/wrapper/gradle-wrapper.properties 24 | 25 | # End of https://www.gitignore.io/api/gradle 26 | -------------------------------------------------------------------------------- /Groovy/README.txt: -------------------------------------------------------------------------------- 1 | Welcome to the Groovy Gilded Rose 2 | ================================= 3 | 4 | to run the test, you can either: 5 | - run them from your favorite IDE 6 | - make sure you have installed language support for Groovy 7 | - IntelliJ: 8 | - open project 9 | - choose this folder (Groovy) 10 | - Eclipse: 11 | - new Groovy Project 12 | - choose this folder (Groovy) as the project folder 13 | - add JUnit to build path 14 | - run the test from the src/ folder in your shell: 15 | - $ cd src/ 16 | - $ groovy com/gildedrose/GildedRoseTest.groovy 17 | 18 | -------------------------------------------------------------------------------- /cpp-catch2/test/gildedrose_catch.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "ApprovalTests.hpp" 3 | 4 | #include "GildedRose.h" 5 | 6 | std::ostream& operator<<(std::ostream& os, const Item& obj) 7 | { 8 | return os 9 | << "name: " << obj.name 10 | << ", sellIn: " << obj.sellIn 11 | << ", quality: " << obj.quality; 12 | } 13 | 14 | TEST_CASE("UpdateQuality") { 15 | 16 | vector items; 17 | items.push_back(Item("foo", 0, 0)); 18 | GildedRose app(items); 19 | app.updateQuality(); 20 | REQUIRE("fixme" == app.items[0].name); 21 | } 22 | -------------------------------------------------------------------------------- /fsharp-core/GildedRose.ApprovalTests/Tests.fs: -------------------------------------------------------------------------------- 1 | module GildedRose.ApprovalTests 2 | 3 | open System 4 | open Xunit 5 | open System.Text 6 | open System.IO 7 | 8 | [] 9 | let ``Thirty day report is correct`` () = 10 | let expected = File.ReadAllText "GildedRoseTest.ApprovalTest.ThirtyDays.received.txt" 11 | 12 | let fakeoutput = new StringBuilder() 13 | Console.SetOut(new StringWriter(fakeoutput)) 14 | Console.SetIn(new StringReader("a\n")) 15 | 16 | GildedRose.Program.main [||] |> ignore 17 | let actual = fakeoutput.ToString() 18 | 19 | Assert.Equal(expected, actual) 20 | -------------------------------------------------------------------------------- /pascal/ROSE_T.PAS: -------------------------------------------------------------------------------- 1 | {F+} { need to set Far Calls in Compiler Options too } 2 | program Rose_T; 3 | 4 | uses TPUnit, Rose; 5 | 6 | var Items: ListOfItems; 7 | 8 | procedure CreateItem; 9 | begin 10 | ResizeList(Items, 1); 11 | end; 12 | 13 | procedure DisposeItem; 14 | begin 15 | ClearList(Items); 16 | end; 17 | 18 | procedure Foo; 19 | begin 20 | InitItem(Items.Elements^[0], 'foo', 0, 0); 21 | 22 | UpdateQuality(Items); 23 | 24 | AssertEqualsStr('name', 'fixme', Items.Elements^[0].Name); 25 | end; 26 | 27 | begin 28 | RunFixtures('foo', CreateItem, Foo, DisposeItem); 29 | end. 30 | -------------------------------------------------------------------------------- /csharpcore/csharpcore.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | csharpcore.Program 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /swift/Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.1 2 | 3 | import PackageDescription 4 | 5 | let package = Package( 6 | name: "GildedRose", 7 | products: [ 8 | .library( 9 | name: "GildedRose", 10 | targets: ["GildedRose"]), 11 | ], 12 | targets: [ 13 | .target( 14 | name: "GildedRose", 15 | dependencies: []), 16 | .target( 17 | name: "GildedRoseApp", 18 | dependencies: ["GildedRose"]), 19 | .testTarget( 20 | name: "GildedRoseTests", 21 | dependencies: ["GildedRose"]), 22 | ] 23 | ) 24 | -------------------------------------------------------------------------------- /c99/test_rose.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "GildedRose.h" 3 | 4 | 5 | 6 | START_TEST(roseFoo) 7 | { 8 | Item items[1]; 9 | init_item(items, "foo", 0, 0); 10 | update_quality(items, 1); 11 | 12 | ck_assert_str_eq("fixme", items[0].name); 13 | } 14 | END_TEST 15 | 16 | TCase *tcase_rose(void) 17 | { 18 | TCase *tc; 19 | 20 | tc = tcase_create("gilded-rose"); 21 | tcase_add_test(tc, roseFoo); 22 | 23 | return tc; 24 | } 25 | 26 | Suite *suite_rose(void) 27 | { 28 | Suite *s; 29 | 30 | s = suite_create("characterization-tests"); 31 | suite_add_tcase(s, tcase_rose()); 32 | 33 | return s; 34 | } 35 | -------------------------------------------------------------------------------- /Delphi/README.md: -------------------------------------------------------------------------------- 1 | # Delphi port of the Gilded-Rose Kata 2 | This is a Delphi port of the *Gilded-Rose-Kata*. 3 | 4 | ## Version Compatibility 5 | The project files are written in Delphi 10.3.3 therefore require 10.3 or later. 6 | That said, the actual code should be compatible back to Delphi 2010 as the unit 7 | tests are written in [DUnitX](https://github.com/VSoftTechnologies/DUnitX) which 8 | requires Delphi 2010 or later. 9 | 10 | ## Building and Running 11 | * Open the project group `GildedRose.groupproj`. 12 | * Build and run the `TextTestFixture.exe` for the text output tests. 13 | * Build and run the `UnitTests.exe` project to execute the unit tests. 14 | -------------------------------------------------------------------------------- /abap/README.md: -------------------------------------------------------------------------------- 1 | # Gilded Rose Refactoring Kata in [ABAP](http://scn.sap.com/community/abap/) 2 | 3 | ## Prerequisite 4 | 5 | Access to SAP NetWeaver server with at least ABAP 7.40 6 | 7 | ## Installation 8 | 9 | Assuming you have a proper developer key set up, run SE38 10 | * create a new Module Pool (type M) program as a Local Object 11 | * paste the raw code from [YY_PAO_GILDED_ROSE.abap](https://raw.githubusercontent.com/brehberg/GildedRose-Refactoring-Kata/master/abap/YY_PAO_GILDED_ROSE.abap) 12 | * save (Ctrl-S) and activate (Ctrl-F3) the program 13 | 14 | ## Running Tests 15 | 16 | From the menus choose Program -> Execute -> Unit Tests (Ctrl+Shift+F10) 17 | -------------------------------------------------------------------------------- /Java-Spock/src/test/groovy/com/gildedrose/GildedRoseSpec.groovy: -------------------------------------------------------------------------------- 1 | package com.gildedrose 2 | 3 | import spock.lang.Specification 4 | 5 | /** 6 | * Spock unit tests. 7 | */ 8 | class GildedRoseSpec extends Specification { 9 | 10 | def "should update quality correctly"() { 11 | 12 | given: "some items" 13 | Item[] items = [new Item("foo", 0, 0)]; 14 | 15 | and: "the application with these items" 16 | GildedRose app = new GildedRose(items); 17 | 18 | when: "updating quality" 19 | app.updateQuality(); 20 | 21 | then: "the quality is correct" 22 | app.items[0].name == "fixme" 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /c99/test_main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | Suite *suite_rose(void); 6 | 7 | int main(int argc, char **argv) 8 | { 9 | Suite *s; 10 | SRunner *runner; 11 | int number_fails; 12 | int forkme = 1; 13 | 14 | if (argc > 1 && strcmp(argv[1], "--nofork") == 0) { 15 | forkme = 0; 16 | } 17 | 18 | s = suite_rose(); 19 | runner = srunner_create(s); 20 | 21 | if (0 == forkme) { 22 | srunner_set_fork_status(runner, CK_NOFORK); 23 | } 24 | 25 | srunner_run_all(runner, CK_NORMAL); 26 | number_fails = srunner_ntests_failed(runner); 27 | 28 | srunner_free(runner); 29 | 30 | return number_fails; 31 | } 32 | -------------------------------------------------------------------------------- /plantuml/history/04_aged-brie.puml: -------------------------------------------------------------------------------- 1 | @startuml 2 | 3 | skinparam backgroundColor transparent 4 | 5 | start 6 | 7 | if (not "Aged Brie") then (yes) 8 | if (quality > 0) then (yes) 9 | :lower quality with 1; 10 | else (no) 11 | endif 12 | else (no) 13 | :increase quality with 1; 14 | endif 15 | 16 | :lower sell in with 1; 17 | 18 | if (sell in < 0) then (yes) 19 | if (not "Aged Brie") then (yes) 20 | if (quality > 0) then (yes) 21 | :lower quality with 1; 22 | else (no) 23 | endif 24 | else (no) 25 | :increase quality with 1; 26 | endif 27 | else (no) 28 | endif 29 | 30 | stop 31 | 32 | @enduml 33 | -------------------------------------------------------------------------------- /ruby/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | GildedRose.rb 4 | 5 | 6 | 7 | 8 | 9 | org.rubypeople.rdt.core.rubybuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.dltk.core.scriptbuilder 15 | 16 | 17 | 18 | 19 | 20 | org.rubypeople.rdt.core.rubynature 21 | org.eclipse.dltk.ruby.core.nature 22 | 23 | 24 | -------------------------------------------------------------------------------- /Ada/Makefile: -------------------------------------------------------------------------------- 1 | AHVEN_INCLUDE:=-aI/usr/share/ada/adainclude/ahven -aI/usr/include/ahven 2 | AHVEN_LIBS:=-aO/usr/lib/x86_64-linux-gnu/ada/adalib/ahven -aO/usr/lib/ahven -aO/usr/lib -shared 3 | ADAFLAGS:=-gnat2012 $(AHVEN_INCLUDE) $(AHVEN_LIBS) 4 | LIBS:=-largs -lahven 5 | 6 | .PHONY: all 7 | all: gilded_rose_tester program 8 | 9 | .PHONY: gilded_rose_tester 10 | gilded_rose_tester: 11 | @gnatmake -q $(ADAFLAGS) gilded_rose_tester $(LIBS) 12 | 13 | .PHONY: test 14 | test: gilded_rose_tester 15 | @./gilded_rose_tester 16 | 17 | .PHONY: program 18 | program: 19 | @gnatmake -q $(ADAFLAGS) program $(LIBS) 20 | 21 | .PHONY: clean 22 | clean: 23 | @gnatclean -q gilded_rose_tester program 24 | -------------------------------------------------------------------------------- /COBOL/mf/test/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | Tests 4 | 5 | 6 | 7 | 8 | 9 | com.microfocus.eclipse.project.cobolBuilder 10 | 11 | 12 | 13 | 14 | com.microfocus.eclipse.mfunit.core.mfUnitBuilder 15 | 16 | 17 | 18 | 19 | 20 | com.microfocus.eclipse.project.cobolNature 21 | com.microfocus.eclipse.mfunit.core.mfUnitNature 22 | 23 | 24 | -------------------------------------------------------------------------------- /cpp-catch2/README.md: -------------------------------------------------------------------------------- 1 | C++ version of Gilded Rose with Catch 2 and Approvals 2 | ====================================================== 3 | 4 | This is a C++ start of the ApprovalTest version of the Gilded Rose Refactoring Kata. See 5 | the [top level readme](https://github.com/emilybache/GildedRose-Refactoring-Kata) 6 | for a general description of the exercise. 7 | 8 | 9 | CMake 10 | ----- 11 | 12 | CMake is included in CLion from JetBrains. Without CMake files 13 | CLion has a hard time to handle c-projects. 14 | 15 | To install CMake (if you don't use CLion) on macOS using brew 16 | 17 | brew install cmake 18 | 19 | Tested on CMake 3.15.3 (included with CLion 2019.3) on macOS 20 | 21 | -------------------------------------------------------------------------------- /d/test/GildedRoseUnitTests.d: -------------------------------------------------------------------------------- 1 | import GildedRose; 2 | 3 | unittest 4 | { 5 | Item[] items = [ Item("Foo", 0, 0)]; 6 | auto app = new GildedRose(items); 7 | 8 | app.updateQuality; 9 | 10 | assert("fixme" == app.items[0].name); 11 | } 12 | 13 | void example() 14 | { 15 | Item[] items = [ 16 | Item("+5 Dexterity Vest", 10, 20), 17 | Item("Aged Brie", 2, 0), 18 | Item("Elixir of the Mongoose", 5, 7), 19 | Item("Sulfuras, Hand of Ragnaros", 0, 80), 20 | Item("Backstage passes to a TAFKAL80ETC concert", 15, 20), 21 | Item("Conjured Mana Cake", 3, 6), 22 | ]; 23 | auto app = new GildedRose(items); 24 | app.updateQuality; 25 | } 26 | -------------------------------------------------------------------------------- /pascal/README.md: -------------------------------------------------------------------------------- 1 | # Pascal port of the Gilded-Rose Kata 2 | 3 | This is a (Turbo) Pascal port of the *Gilded-Rose-Kata*. 4 | 5 | ## Building and Running 6 | 7 | * Compile the unit `ROSE.PAS`, this is the Gilded Rose Logic. 8 | * Compile the application `TEXTTEST.PAS` for the Texttest fixture. 9 | * Run `TEXTTEST`. 10 | 11 | ## Unit Test 12 | 13 | `TPUNIT.PAS` is a minimalist implementation of xUnit in Pascal style. 14 | There are several assertions available, e.g. `AssertEquals`, `AssertEqualsStr`, `AssertTrue` etc. 15 | It needs _Far Calls_ enabled in compiler options. 16 | 17 | * First compile the unit `TPUNIT.PAS`. 18 | * Then compile application `ROSE_T.PAS`. 19 | * Run `ROSE_T` to run the tests. 20 | -------------------------------------------------------------------------------- /csharpcore/ApprovalTest.cs: -------------------------------------------------------------------------------- 1 | using Xunit; 2 | using System; 3 | using System.IO; 4 | using System.Text; 5 | using ApprovalTests; 6 | using ApprovalTests.Reporters; 7 | 8 | namespace csharpcore 9 | { 10 | [UseReporter(typeof(DiffReporter))] 11 | public class ApprovalTest 12 | { 13 | [Fact] 14 | public void ThirtyDays() 15 | { 16 | var fakeoutput = new StringBuilder(); 17 | Console.SetOut(new StringWriter(fakeoutput)); 18 | Console.SetIn(new StringReader("a\n")); 19 | 20 | Program.Main(new string[] { }); 21 | var output = fakeoutput.ToString(); 22 | 23 | Approvals.Verify(output); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /elm/elm.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "application", 3 | "source-directories": [ 4 | "src" 5 | ], 6 | "elm-version": "0.19.1", 7 | "dependencies": { 8 | "direct": { 9 | "elm/browser": "1.0.2", 10 | "elm/core": "1.0.4", 11 | "elm/html": "1.0.0" 12 | }, 13 | "indirect": { 14 | "elm/json": "1.1.3", 15 | "elm/time": "1.0.0", 16 | "elm/url": "1.0.0", 17 | "elm/virtual-dom": "1.0.2" 18 | } 19 | }, 20 | "test-dependencies": { 21 | "direct": { 22 | "elm-explorations/test": "1.2.2" 23 | }, 24 | "indirect": { 25 | "elm/random": "1.0.0" 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Kotlin/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.3.41' 3 | 4 | repositories { 5 | mavenCentral() 6 | } 7 | 8 | dependencies { 9 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 10 | } 11 | } 12 | 13 | plugins { 14 | id "org.jetbrains.kotlin.jvm" version "1.3.41" 15 | } 16 | 17 | apply plugin: 'kotlin' 18 | 19 | dependencies { 20 | compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" 21 | testCompile 'junit:junit:4.12' 22 | } 23 | repositories { 24 | mavenCentral() 25 | } 26 | compileKotlin { 27 | kotlinOptions { 28 | jvmTarget = "1.8" 29 | } 30 | } 31 | compileTestKotlin { 32 | kotlinOptions { 33 | jvmTarget = "1.8" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /csharp/ApprovalTest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Text; 4 | using ApprovalTests; 5 | using ApprovalTests.Reporters; 6 | using NUnit.Framework; 7 | 8 | namespace csharp 9 | { 10 | [UseReporter(typeof(DiffReporter))] 11 | [TestFixture] 12 | public class ApprovalTest 13 | { 14 | [Test] 15 | public void ThirtyDays() 16 | { 17 | 18 | StringBuilder fakeoutput = new StringBuilder(); 19 | Console.SetOut(new StringWriter(fakeoutput)); 20 | Console.SetIn(new StringReader("a\n")); 21 | 22 | Program.Main(new string[] { }); 23 | var output = fakeoutput.ToString(); 24 | 25 | Approvals.Verify(output); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /haskell/README.md: -------------------------------------------------------------------------------- 1 | # Haskell port of the Gilded-Rose Kata 2 | 3 | This is a Haskell port of the *Gilded-Rose-Kata*. 4 | 5 | ## Prerequisite 6 | 7 | If you don't have a recent Stack version installed in your system, follow the 8 | [installation instructions](https://docs.haskellstack.org/en/stable/install_and_upgrade/) 9 | for your operating system. 10 | 11 | ## Building and Running 12 | 13 | Run `stack build` initially, then `stack test` to execute the tests after 14 | each refactoring. 15 | 16 | To execute the program run `stack run [days]` where `[days]` denotes an optional 17 | parameter for the number of days to simulate. 18 | 19 | Tests are in `test/GildedRoseSpec.hs`. Refer to http://hspec.github.io/ for 20 | more information about writing tests using `Hspec`. 21 | -------------------------------------------------------------------------------- /Groovy/.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /js-jest/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gilded-rose-kata", 3 | "version": "1.0.0", 4 | "description": "Gilded Rose kata in JavaScript with Jest", 5 | "scripts": { 6 | "test": "jest", 7 | "test:watch": "jest --watch", 8 | "test:coverage": "jest --coverage" 9 | }, 10 | "repository": { 11 | "type": "git", 12 | "url": "git+https://github.com/emilybache/GildedRose-Refactoring-Kata.git" 13 | }, 14 | "keywords": [ 15 | "kata", 16 | "refactor", 17 | "gilded-rose" 18 | ], 19 | "license": "MIT", 20 | "private": true, 21 | "bugs": { 22 | "url": "https://github.com/emilybache/GildedRose-Refactoring-Kata/issues" 23 | }, 24 | "homepage": "https://github.com/emilybache/GildedRose-Refactoring-Kata", 25 | "devDependencies": { 26 | "jest": "^24.9.0" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /js-mocha/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gilded-rose-kata", 3 | "version": "1.0.0", 4 | "description": "Gilded Rose kata in Javascript with Mocha", 5 | "scripts": { 6 | "test": "mocha --compilers js:babel/register" 7 | }, 8 | "repository": { 9 | "type": "git", 10 | "url": "git+https://github.com/emilybache/GildedRose-Refactoring-Kata.git" 11 | }, 12 | "keywords": [ 13 | "kata", 14 | "refactor", 15 | "gilded-rose" 16 | ], 17 | "license": "MIT", 18 | "private": true, 19 | "bugs": { 20 | "url": "https://github.com/emilybache/GildedRose-Refactoring-Kata/issues" 21 | }, 22 | "homepage": "https://github.com/emilybache/GildedRose-Refactoring-Kata", 23 | "devDependencies": { 24 | "babel": "^5.8.23", 25 | "chai": "^4.2.0", 26 | "mocha": "^5.2.0" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /php5/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | GildedRose.php 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.wst.validation.validationbuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.dltk.core.scriptbuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.wst.common.project.facet.core.builder 20 | 21 | 22 | 23 | 24 | 25 | org.eclipse.wst.common.project.facet.core.nature 26 | org.eclipse.php.core.PHPNature 27 | 28 | 29 | -------------------------------------------------------------------------------- /xslt/README.md: -------------------------------------------------------------------------------- 1 | # XSLT port of the Gilded-Rose Kata 2 | 3 | This is a XSLT 1.0 port of the *Gilded-Rose-Kata*. 4 | 5 | ## Building and Running 6 | 7 | * [Apache Ant's XSLT task](https://ant.apache.org/manual/Tasks/style.html) is used to run the transformations. 8 | * `update_quality.xsl` contains the Gilded Rose logic. 9 | * Run Ant in the current folder to transform all files. 10 | * `texttest_fixture.xml` is transformed into `texttest_fixture.next_day.xml` with updated values. 11 | 12 | ## Unit Test 13 | 14 | [xsltunit](http://xsltunit.org/) is a implementation of xUnit in XSLT. 15 | 16 | * `tst_update_quality.xsl`is the the test (stylesheet). 17 | * Run Ant in the current folder to run the tests. 18 | * `update_quality.test_result.xml` contains the results and 19 | `update_quality.test_result.html` is a readable report. 20 | -------------------------------------------------------------------------------- /cpp/test/cpp_catch2_unittest/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(TEST_NAME GildedRoseCatch2UnitTests) 2 | add_executable(${TEST_NAME}) 3 | target_sources(${TEST_NAME} PRIVATE GildedRoseCatch2UnitTests.cc) 4 | target_link_libraries(${TEST_NAME} lib src) 5 | set_property(TARGET ${TEST_NAME} PROPERTY CXX_STANDARD 11) 6 | add_test(NAME ${TEST_NAME} COMMAND ${TEST_NAME}) 7 | 8 | # Set compiler option /FC for Visual Studio to to make the __FILE__ macro expand to full path. 9 | # The __FILE__ macro is used by Catch2 to get the path to current test file. 10 | # Links: 11 | # * https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=vs-2019 12 | # * https://docs.microsoft.com/en-us/cpp/build/reference/fc-full-path-of-source-code-file-in-diagnostics?view=vs-2019 13 | if (MSVC) 14 | target_compile_options(${TEST_NAME} PRIVATE "/FC") 15 | endif() 16 | -------------------------------------------------------------------------------- /cpp/test/cpp_texttest/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(TEST_NAME GildedRoseTextTests) 2 | add_executable(${TEST_NAME} GildedRoseTextTests.cc) 3 | target_sources(${TEST_NAME} PRIVATE GildedRoseTextTests.cc) 4 | target_link_libraries(${TEST_NAME} lib src) 5 | set_property(TARGET ${TEST_NAME} PROPERTY CXX_STANDARD 11) 6 | add_test(NAME ${TEST_NAME} COMMAND ${TEST_NAME}) 7 | 8 | # Set compiler option /FC for Visual Studio to to make the __FILE__ macro expand to full path. 9 | # The __FILE__ macro is used by Catch2 to get the path to current test file. 10 | # Links: 11 | # * https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=vs-2019 12 | # * https://docs.microsoft.com/en-us/cpp/build/reference/fc-full-path-of-source-code-file-in-diagnostics?view=vs-2019 13 | if (MSVC) 14 | target_compile_options(${TEST_NAME} PRIVATE "/FC") 15 | endif() 16 | -------------------------------------------------------------------------------- /plantuml/history/05_quality-max-50.puml: -------------------------------------------------------------------------------- 1 | @startuml 2 | 3 | skinparam backgroundColor transparent 4 | 5 | start 6 | 7 | if (not "Aged Brie") then (yes) 8 | if (quality > 0) then (yes) 9 | :lower quality with 1; 10 | else (no) 11 | endif 12 | else (no) 13 | if (quality < 50) then (yes) 14 | :increase quality with 1; 15 | else (no) 16 | endif 17 | endif 18 | 19 | :lower sell in with 1; 20 | 21 | if (sell in < 0) then (yes) 22 | if (not "Aged Brie") then (yes) 23 | if (quality > 0) then (yes) 24 | :lower quality with 1; 25 | else (no) 26 | endif 27 | else (no) 28 | if (quality < 50) then (yes) 29 | :increase quality with 1; 30 | else (no) 31 | endif 32 | endif 33 | else (no) 34 | endif 35 | 36 | stop 37 | 38 | @enduml 39 | -------------------------------------------------------------------------------- /cpp/test/cpp_catch2_approvaltest/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(TEST_NAME GildedRoseCatch2ApprovalTests) 2 | add_executable(${TEST_NAME}) 3 | target_sources(${TEST_NAME} PRIVATE GildedRoseCatch2ApprovalTests.cc) 4 | target_link_libraries(${TEST_NAME} lib src) 5 | set_property(TARGET ${TEST_NAME} PROPERTY CXX_STANDARD 11) 6 | add_test(NAME ${TEST_NAME} COMMAND ${TEST_NAME}) 7 | 8 | # Set compiler option /FC for Visual Studio to to make the __FILE__ macro expand to full path. 9 | # The __FILE__ macro is used by Catch2 to get the path to current test file. 10 | # Links: 11 | # * https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=vs-2019 12 | # * https://docs.microsoft.com/en-us/cpp/build/reference/fc-full-path-of-source-code-file-in-diagnostics?view=vs-2019 13 | if (MSVC) 14 | target_compile_options(${TEST_NAME} PRIVATE "/FC") 15 | endif() 16 | -------------------------------------------------------------------------------- /cpp/test/cpp_googletest_unittest/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(TEST_NAME GildedRoseGoogletestUnitTests) 2 | add_executable(${TEST_NAME}) 3 | target_sources(${TEST_NAME} PRIVATE GildedRoseGoogletestUnitTests.cc) 4 | target_link_libraries(${TEST_NAME} src gtest gtest_main) 5 | set_property(TARGET ${TEST_NAME} PROPERTY CXX_STANDARD 11) 6 | add_test(NAME ${TEST_NAME} COMMAND ${TEST_NAME}) 7 | 8 | # Set compiler option /FC for Visual Studio to to make the __FILE__ macro expand to full path. 9 | # The __FILE__ macro can be used to get the path to current test file. 10 | # Links: 11 | # * https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=vs-2019 12 | # * https://docs.microsoft.com/en-us/cpp/build/reference/fc-full-path-of-source-code-file-in-diagnostics?view=vs-2019 13 | if (MSVC) 14 | target_compile_options(${TEST_NAME} PRIVATE "/FC") 15 | endif() 16 | -------------------------------------------------------------------------------- /Delphi/GildedRoseTests.pas: -------------------------------------------------------------------------------- 1 | unit GildedRoseTests; 2 | 3 | interface 4 | uses 5 | DUnitX.TestFramework, 6 | GildedRose, 7 | Item, 8 | System.Generics.Collections; 9 | 10 | type 11 | [TestFixture] 12 | TGildedRoseTests = class(TObject) 13 | public 14 | [Test] 15 | procedure UpdateQuality_Never_ChangesTheItemName; 16 | end; 17 | 18 | implementation 19 | 20 | procedure TGildedRoseTests.UpdateQuality_Never_ChangesTheItemName; 21 | var 22 | LItems: TObjectList; 23 | LGildedRose: TGildedRose; 24 | begin 25 | LItems := TObjectList.Create; 26 | LItems.Add(TItem.Create('foo', 0, 0)); 27 | LGildedRose := TGildedRose.Create(LItems); 28 | 29 | LGildedRose.UpdateQuality; 30 | 31 | Assert.AreEqual('fixme', LGildedRose.Items[0].Name); 32 | end; 33 | 34 | initialization 35 | TDUnitX.RegisterTestFixture(TGildedRoseTests); 36 | end. 37 | -------------------------------------------------------------------------------- /cpp/test/cpp_googletest_approvaltest/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(TEST_NAME GildedRoseGoogletestApprovalTests) 2 | add_executable(${TEST_NAME}) 3 | target_sources(${TEST_NAME} PRIVATE googletest_approval_main.cc GildedRoseGoogletestApprovalTests.cc) 4 | target_link_libraries(${TEST_NAME} lib src gtest) 5 | set_property(TARGET ${TEST_NAME} PROPERTY CXX_STANDARD 11) 6 | add_test(NAME ${TEST_NAME} COMMAND ${TEST_NAME}) 7 | 8 | # Set compiler option /FC for Visual Studio to to make the __FILE__ macro expand to full path. 9 | # The __FILE__ macro can be used to get the path to current test file. 10 | # Links: 11 | # * https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=vs-2019 12 | # * https://docs.microsoft.com/en-us/cpp/build/reference/fc-full-path-of-source-code-file-in-diagnostics?view=vs-2019 13 | if (MSVC) 14 | target_compile_options(${TEST_NAME} PRIVATE "/FC") 15 | endif() 16 | -------------------------------------------------------------------------------- /Ada/items.adb: -------------------------------------------------------------------------------- 1 | with Ada.Strings.Unbounded; 2 | use Ada.Strings.Unbounded; 3 | 4 | package body Items is 5 | function Integer_Image(Self : in Integer) return String is 6 | Img : constant String := Integer'Image(Self); 7 | begin 8 | if Self < 0 then 9 | return Img; 10 | else 11 | return Img(2 .. Img'Length); 12 | end if; 13 | end; 14 | 15 | function To_String(Self : in Item) return String is 16 | Name : constant Unbounded_String := Self.Name; 17 | Sell_In : constant Unbounded_String := To_Unbounded_String(Integer_Image(Self.Sell_In)); 18 | Quality : constant Unbounded_String := To_Unbounded_String(Integer_Image(Self.Quality)); 19 | 20 | Ret : Unbounded_String; 21 | begin 22 | Append(Ret, Name); 23 | Append(Ret, ", "); 24 | Append(Ret, Sell_In); 25 | Append(Ret, ", "); 26 | Append(Ret, Quality); 27 | 28 | return To_String(Ret); 29 | end; 30 | 31 | end Items; 32 | -------------------------------------------------------------------------------- /sql/test/data/load.sql: -------------------------------------------------------------------------------- 1 | DELETE FROM item; 2 | 3 | INSERT INTO item (name, sellIn, quality) VALUES ('+5 Dexterity Vest', 10, 20); 4 | INSERT INTO item (name, sellIn, quality) VALUES ('Aged Brie', 2, 0); 5 | INSERT INTO item (name, sellIn, quality) VALUES ('Elixir of the Mongoose', 5, 7); 6 | INSERT INTO item (name, sellIn, quality) VALUES ('Sulfuras, Hand of Ragnaros', 0, 80); 7 | INSERT INTO item (name, sellIn, quality) VALUES ('Sulfuras, Hand of Ragnaros', -1, 80); 8 | INSERT INTO item (name, sellIn, quality) VALUES ('Backstage passes to a TAFKAL80ETC concert', 15, 20); 9 | INSERT INTO item (name, sellIn, quality) VALUES ('Backstage passes to a TAFKAL80ETC concert', 10, 49); 10 | INSERT INTO item (name, sellIn, quality) VALUES ('Backstage passes to a TAFKAL80ETC concert', 5, 49); 11 | 12 | -- this conjured item does not work properly yet 13 | INSERT INTO item (name, sellIn, quality) VALUES ('Conjured Mana Cake', 3, 6); 14 | 15 | COMMIT; 16 | -------------------------------------------------------------------------------- /Delphi/Item.pas: -------------------------------------------------------------------------------- 1 | unit Item; 2 | 3 | interface 4 | 5 | type 6 | TItem = class(TObject) 7 | private 8 | FName: string; 9 | FSellIn: Integer; 10 | FQuality: Integer; 11 | public 12 | constructor Create(const AName: string; const ASellIn, AQuality: Integer); 13 | function ToString: string; override; 14 | property Name: string read FName write FName; 15 | property SellIn: Integer read FSellIn write FSellIn; 16 | property Quality: Integer read FQuality write FQuality; 17 | end; 18 | 19 | implementation 20 | 21 | uses 22 | System.SysUtils; 23 | 24 | { TItem } 25 | 26 | constructor TItem.Create(const AName: string; const ASellIn, AQuality: Integer); 27 | begin 28 | inherited Create; 29 | FName := AName; 30 | FSellIn := ASellIn; 31 | FQuality := AQuality; 32 | end; 33 | 34 | function TItem.ToString: string; 35 | begin 36 | Result := Format('%s, %d, %d', [Name, SellIn, Quality]); 37 | end; 38 | 39 | end. 40 | -------------------------------------------------------------------------------- /cpp/test/cpp_catch2_approvaltest/GildedRoseCatch2ApprovalTests.cc: -------------------------------------------------------------------------------- 1 | #define APPROVALS_CATCH 2 | #include "ApprovalTests.hpp" 3 | #include "GildedRose.h" 4 | 5 | std::ostream& operator<<(std::ostream& os, const Item& obj) 6 | { 7 | return os 8 | << "name: " << obj.name 9 | << ", sellIn: " << obj.sellIn 10 | << ", quality: " << obj.quality; 11 | } 12 | 13 | TEST_CASE("GildedRoseApprovalTests", "VerifyCombinations") 14 | { 15 | std::vector names { "Foo" }; 16 | std::vector sellIns { 1 }; 17 | std::vector qualities { 1 }; 18 | 19 | auto f = [](string name, int sellIn, int quality) { 20 | vector items = {Item(name, sellIn, quality)}; 21 | GildedRose app(items); 22 | app.updateQuality(); 23 | return items[0]; 24 | }; 25 | 26 | ApprovalTests::CombinationApprovals::verifyAllCombinations( 27 | f, 28 | names, sellIns, qualities); 29 | } 30 | -------------------------------------------------------------------------------- /TypeScript/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gilded-rose-kata", 3 | "version": "1.0.0", 4 | "description": "Gilded Rose kata in TypeScript", 5 | "scripts": { 6 | "precompile": "rimraf app/**/*.js test/**/*.js", 7 | "compile": "tsc", 8 | "pretest": "rimraf app/**/*.js test/**/*.js", 9 | "test": "nyc mocha" 10 | }, 11 | "license": "MIT", 12 | "private": true, 13 | "devDependencies": { 14 | "@types/chai": "~3.5.2", 15 | "@types/mocha": "~2.2.41", 16 | "@types/node": "~7.0.18", 17 | "chai": "~3.5.0", 18 | "mocha": "~3.2.0", 19 | "nyc": "~11.0.3", 20 | "rimraf": "~2.5.2", 21 | "source-map-support": "0.5.9", 22 | "ts-node": "~3.1.0", 23 | "typescript": "~3.0.3" 24 | }, 25 | "nyc": { 26 | "extension": [ 27 | ".ts" 28 | ], 29 | "exclude": [ 30 | "**/*.d.ts", 31 | "test/**" 32 | ], 33 | "require": [ 34 | "ts-node/register" 35 | ], 36 | "reporter": [ 37 | "html", 38 | "text" 39 | ] 40 | } 41 | } 42 | 43 | -------------------------------------------------------------------------------- /R/texttest_fixture.R: -------------------------------------------------------------------------------- 1 | rm(list=ls()) 2 | 3 | source('gilded_rose.R') 4 | 5 | writeLines('OMGHAI!') 6 | 7 | items <- list( 8 | item('+5 Dexterity Vest', 10, 20), 9 | item('Aged Brie', 2, 0), 10 | item('Elixir of the Mongoose', 5, 7), 11 | item('Sulfuras, Hand of Ragnaros', 0, 80), 12 | item('Sulfuras, Hand of Ragnaros', -1, 80), 13 | item('Backstage passes to a TAFKAL80ETC concert', 15, 20), 14 | item('Backstage passes to a TAFKAL80ETC concert', 10, 49), 15 | item('Backstage passes to a TAFKAL80ETC concert', 5, 49), 16 | # This Conjured item does not work properly yet 17 | item('Conjured Mana Cake', 3, 6) 18 | ) 19 | 20 | days <- 2 21 | for (day in 0:days) { 22 | writeLines(paste('-------- day ', day, ' --------', sep='')) 23 | writeLines('name, sellIn, quality') 24 | lapply(items, 25 | function(item) { 26 | writeLines(as.character(item)) 27 | } 28 | ) 29 | writeLines('') 30 | items <- update_quality(items) 31 | } 32 | 33 | rm('day', 'days', 'items') 34 | -------------------------------------------------------------------------------- /texttests/config.gr: -------------------------------------------------------------------------------- 1 | full_name:Gilded Rose Refactoring Kata 2 | 3 | # set your preferred editor and diff tool. 4 | view_program:subl 5 | diff_program:meld 6 | 7 | # Settings for the Python version 8 | #executable:${TEXTTEST_HOME}/python/texttest_fixture.py 9 | #interpreter:python 10 | 11 | # Settings for the cpp version 12 | #executable:${TEXTTEST_HOME}/cpp/cmake-build-debug/test/cpp_texttest/GildedRoseTextTests 13 | 14 | # Settings for the Java version 15 | #executable:com.gildedrose.TexttestFixture 16 | #interpreter:java 17 | # note you'll also need to update the file environment.gr with your classpath if you keep your classfiles somewhere unusual 18 | 19 | # Settings for the Ruby version 20 | #executable:${TEXTTEST_HOME}/ruby/texttest_fixture.rb 21 | #interpreter:ruby 22 | 23 | # Settings for the C# version 24 | #executable:${TEXTTEST_HOME}/GildedRose.exe 25 | 26 | # Settings for the Perl version 27 | #executable:${TEXTTEST_HOME}/perl/texttest_fixture.pl 28 | #interpreter:perl 29 | 30 | 31 | filename_convention_scheme:standard 32 | -------------------------------------------------------------------------------- /xslt/texttest_fixture.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | OMGHAI! 5 | 0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /js-jasmine/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gilded-rose-kata", 3 | "version": "1.0.0", 4 | "description": "Gilded Rose kata in Javascript with Jasmine", 5 | "scripts": { 6 | "test": "jasmine" 7 | }, 8 | "repository": { 9 | "type": "git", 10 | "url": "git+https://github.com/emilybache/GildedRose-Refactoring-Kata.git" 11 | }, 12 | "keywords": [ 13 | "kata", 14 | "refactor", 15 | "gilded-rose" 16 | ], 17 | "license": "MIT", 18 | "private": true, 19 | "bugs": { 20 | "url": "https://github.com/emilybache/GildedRose-Refactoring-Kata/issues" 21 | }, 22 | "homepage": "https://github.com/emilybache/GildedRose-Refactoring-Kata", 23 | "devDependencies": { 24 | "babel-core": "^6.26.0", 25 | "babel-preset-env": "1.7.0", 26 | "babel-register": "^6.26.0", 27 | "jasmine": "^3.2.0" 28 | }, 29 | "babel": { 30 | "presets": [ 31 | [ 32 | "env", { 33 | "targets": { "node": "current" } 34 | } 35 | ] 36 | ], 37 | "plugins": [] 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /cpp/test/cpp_googletest_approvaltest/GildedRoseGoogletestApprovalTests.cc: -------------------------------------------------------------------------------- 1 | // Include header files for test frameworks 2 | #include 3 | #include 4 | 5 | // Include code to be tested 6 | #include "GildedRose.h" 7 | 8 | std::ostream& operator<<(std::ostream& os, const Item& obj) 9 | { 10 | return os 11 | << "name: " << obj.name 12 | << ", sellIn: " << obj.sellIn 13 | << ", quality: " << obj.quality; 14 | } 15 | 16 | TEST(GildedRoseApprovalTests, VerifyCombinations) { 17 | 18 | std::vector names { "Foo" }; 19 | std::vector sellIns { 1 }; 20 | std::vector qualities { 1 }; 21 | 22 | auto f = [](string name, int sellIn, int quality) { 23 | vector items = {Item(name, sellIn, quality)}; 24 | GildedRose app(items); 25 | app.updateQuality(); 26 | return items[0]; 27 | }; 28 | 29 | ApprovalTests::CombinationApprovals::verifyAllCombinations( 30 | f, 31 | names, sellIns, qualities); 32 | 33 | } 34 | -------------------------------------------------------------------------------- /csharp/csharp.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "csharp", "csharp.csproj", "{176C0214-9136-4079-8DAB-11D7420C3881}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {176C0214-9136-4079-8DAB-11D7420C3881}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {176C0214-9136-4079-8DAB-11D7420C3881}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {176C0214-9136-4079-8DAB-11D7420C3881}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {176C0214-9136-4079-8DAB-11D7420C3881}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /fsharp-core/GildedRose.UnitTests/GildedRose.UnitTests.fsproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp2.1 5 | 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | all 19 | runtime; build; native; contentfiles; analyzers 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /fsharp/GildedRose.Tests/GildedRoseTest.fs: -------------------------------------------------------------------------------- 1 | module GildedRoseTest 2 | 3 | open GildedRose 4 | open System 5 | open System.IO 6 | open System.Text 7 | open NUnit.Framework 8 | open System.Collections.Generic 9 | open ApprovalTests 10 | open ApprovalTests.Reporters 11 | 12 | [] 13 | type GildedRoseTest () as this = 14 | [] member this.Foo ()= 15 | let Items = new List() 16 | Items.Add({Name = "foo"; SellIn = 0; Quality = 0}) 17 | let app = new GildedRose(Items) 18 | app.UpdateQuality() 19 | Assert.AreEqual("fixme", Items.[0].Name) 20 | 21 | [] 22 | [)>] 23 | type ApprovalTest () as this = 24 | [] member this.ThirtyDays ()= 25 | let fakeoutput = new StringBuilder() 26 | Console.SetOut(new StringWriter(fakeoutput)) 27 | Console.SetIn(new StringReader("a\n")) 28 | 29 | main Array.empty 30 | let output = fakeoutput.ToString() 31 | Approvals.Verify(output) 32 | () -------------------------------------------------------------------------------- /js-jest/test/texttest_fixture.js: -------------------------------------------------------------------------------- 1 | 2 | const { Shop, Item } = require("../src/gilded_rose"); 3 | 4 | const items = [ 5 | new Item("+5 Dexterity Vest", 10, 20), 6 | new Item("Aged Brie", 2, 0), 7 | new Item("Elixir of the Mongoose", 5, 7), 8 | new Item("Sulfuras, Hand of Ragnaros", 0, 80), 9 | new Item("Sulfuras, Hand of Ragnaros", -1, 80), 10 | new Item("Backstage passes to a TAFKAL80ETC concert", 15, 20), 11 | new Item("Backstage passes to a TAFKAL80ETC concert", 10, 49), 12 | new Item("Backstage passes to a TAFKAL80ETC concert", 5, 49), 13 | 14 | // This Conjured item does not work properly yet 15 | new Item("Conjured Mana Cake", 3, 6), 16 | ]; 17 | 18 | const days = Number(process.argv[2]) || 2; 19 | const gildedRose = new Shop(items); 20 | 21 | console.log("OMGHAI!"); 22 | for (let day = 0; day < days; day++) { 23 | console.log(`\n-------- day ${day} --------`); 24 | console.log("name, sellIn, quality"); 25 | items.forEach(item => console.log(`${item.name}, ${item.sellIn}, ${item.quality}`)); 26 | gildedRose.updateQuality(); 27 | } 28 | -------------------------------------------------------------------------------- /js-mocha/test/texttest_fixture.js: -------------------------------------------------------------------------------- 1 | 2 | const { Shop, Item } = require("../src/gilded_rose"); 3 | 4 | const items = [ 5 | new Item("+5 Dexterity Vest", 10, 20), 6 | new Item("Aged Brie", 2, 0), 7 | new Item("Elixir of the Mongoose", 5, 7), 8 | new Item("Sulfuras, Hand of Ragnaros", 0, 80), 9 | new Item("Sulfuras, Hand of Ragnaros", -1, 80), 10 | new Item("Backstage passes to a TAFKAL80ETC concert", 15, 20), 11 | new Item("Backstage passes to a TAFKAL80ETC concert", 10, 49), 12 | new Item("Backstage passes to a TAFKAL80ETC concert", 5, 49), 13 | 14 | // This Conjured item does not work properly yet 15 | new Item("Conjured Mana Cake", 3, 6), 16 | ]; 17 | 18 | const days = Number(process.argv[2]) || 2; 19 | const gildedRose = new Shop(items); 20 | 21 | console.log("OMGHAI!"); 22 | for (let day = 0; day < days; day++) { 23 | console.log(`\n-------- day ${day} --------`); 24 | console.log("name, sellIn, quality"); 25 | items.forEach(item => console.log(`${item.name}, ${item.sellIn}, ${item.quality}`)); 26 | gildedRose.updateQuality(); 27 | } 28 | -------------------------------------------------------------------------------- /js-jasmine/spec/texttest_fixture.js: -------------------------------------------------------------------------------- 1 | 2 | const { Shop, Item } = require("../src/gilded_rose"); 3 | 4 | const items = [ 5 | new Item("+5 Dexterity Vest", 10, 20), 6 | new Item("Aged Brie", 2, 0), 7 | new Item("Elixir of the Mongoose", 5, 7), 8 | new Item("Sulfuras, Hand of Ragnaros", 0, 80), 9 | new Item("Sulfuras, Hand of Ragnaros", -1, 80), 10 | new Item("Backstage passes to a TAFKAL80ETC concert", 15, 20), 11 | new Item("Backstage passes to a TAFKAL80ETC concert", 10, 49), 12 | new Item("Backstage passes to a TAFKAL80ETC concert", 5, 49), 13 | 14 | // This Conjured item does not work properly yet 15 | new Item("Conjured Mana Cake", 3, 6), 16 | ]; 17 | 18 | const days = Number(process.argv[2]) || 2; 19 | const gildedRose = new Shop(items); 20 | 21 | console.log("OMGHAI!"); 22 | for (let day = 0; day < days; day++) { 23 | console.log(`\n-------- day ${day} --------`); 24 | console.log("name, sellIn, quality"); 25 | items.forEach(item => console.log(`${item.name}, ${item.sellIn}, ${item.quality}`)); 26 | gildedRose.updateQuality(); 27 | } 28 | -------------------------------------------------------------------------------- /php5/src/texttest_fixture.php: -------------------------------------------------------------------------------- 1 | 1) { 24 | $days = (int) $argv[1]; 25 | } 26 | 27 | for ($i = 0; $i < $days; $i++) { 28 | echo("-------- day $i --------\n"); 29 | echo("name, sellIn, quality\n"); 30 | foreach ($items as $item) { 31 | echo $item . PHP_EOL; 32 | } 33 | echo PHP_EOL; 34 | $app->update_quality(); 35 | } 36 | -------------------------------------------------------------------------------- /c99/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.4) 2 | project(GildedRose_c99) 3 | 4 | enable_testing() 5 | 6 | include(ExternalProject) 7 | ExternalProject_Add(unity 8 | GIT_REPOSITORY https://github.com/ThrowTheSwitch/Unity.git 9 | GIT_TAG master 10 | SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/unity-src" 11 | BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/unity-build" 12 | CONFIGURE_COMMAND "" 13 | BUILD_COMMAND "" 14 | INSTALL_COMMAND "" 15 | TEST_COMMAND "" 16 | ) 17 | add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/unity-src/src/unity.c 18 | DEPENDS unity 19 | COMMAND "") 20 | 21 | 22 | add_executable( GildedRose_Unity 23 | GildedRose.c 24 | ${CMAKE_CURRENT_BINARY_DIR}/unity-src/src/unity.c 25 | test_unity_gildedrose.c 26 | ) 27 | target_include_directories(GildedRose_Unity PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/unity-src/src/) 28 | set_property(TARGET GildedRose_Unity PROPERTY C_STANDARD 99) 29 | add_dependencies(GildedRose_Unity unity) 30 | 31 | add_test(NAME GildedRose_Unity COMMAND GildedRose_Unity) 32 | -------------------------------------------------------------------------------- /TypeScript/test/golden-master-text-test.ts: -------------------------------------------------------------------------------- 1 | import { Item, GildedRose } from '../app/gilded-rose'; 2 | 3 | const items = [ 4 | new Item("+5 Dexterity Vest", 10, 20), // 5 | new Item("Aged Brie", 2, 0), // 6 | new Item("Elixir of the Mongoose", 5, 7), // 7 | new Item("Sulfuras, Hand of Ragnaros", 0, 80), // 8 | new Item("Sulfuras, Hand of Ragnaros", -1, 80), 9 | new Item("Backstage passes to a TAFKAL80ETC concert", 15, 20), 10 | new Item("Backstage passes to a TAFKAL80ETC concert", 10, 49), 11 | new Item("Backstage passes to a TAFKAL80ETC concert", 5, 49), 12 | // this conjured item does not work properly yet 13 | new Item("Conjured Mana Cake", 3, 6)]; 14 | 15 | 16 | const gildedRose = new GildedRose(items); 17 | var days: number = 2; 18 | for (let i = 0; i < days; i++) { 19 | console.log("-------- day " + i + " --------"); 20 | console.log("name, sellIn, quality"); 21 | items.forEach(element => { 22 | console.log(element.name + ' ' + element.sellIn + ' ' + element.quality); 23 | 24 | }); 25 | console.log(); 26 | gildedRose.updateQuality(); 27 | } -------------------------------------------------------------------------------- /GildedRoseRequirements_zh.txt: -------------------------------------------------------------------------------- 1 | ====================================== 2 | Gilded Rose 需求描述 3 | ====================================== 4 | 5 | 6 | 欢迎来到镶金玫瑰(Gilded Rose)团队。如你所知,我们是主城中的一个小旅店,店主非常友好,名叫Allison。我们也售卖最好的物品。不幸的是,物品品质会随着销售期限的接近而不断下降。 7 | 我们有一个系统来更新库存信息。系统是由一个无名之辈Leeroy所开发的,他已经不在这了。 8 | 你的任务是添加新功能,这样我们就可以售卖新的物品。 9 | 10 | 先介绍一下我们的系统: 11 | 12 | - 每种物品都具备一个`SellIn`值,表示我们要在多少天之前把物品卖出去,即销售期 13 | - 每种的物品都具备一个`Quality`值,表示物品的品质 14 | - 每天结束时,系统会降低每种物品的这两个数值 15 | 16 | 很简单吧?这还有些更有意思的: 17 | 18 | - 一旦销售期限过期,品质`Quality`会以双倍速度加速下降 19 | - 物品的品质`Quality`永远不会为负值 20 | - "Aged Brie"的品质`Quality`会随着时间推移而提高 21 | - 物品的品质`Quality`永远不会超过50 22 | - 传奇物品"Sulfuras"永不到期,也不会降低品质`Quality` 23 | - "Backstage passes"与aged brie类似,其品质`Quality`会随着时间推移而提高;当还剩10天或更少的时候,品质`Quality`每天提高2;当还剩5天或更少的时候,品质`Quality`每天提高3;但一旦过期,品质就会降为0 24 | 25 | 26 | 我们最近签约了一个召唤物品供应商。这需要对我们的系统进行升级: 27 | 28 | - "Conjured"物品的品质`Quality`下降速度比正常物品快一倍 29 | 30 | 请随意对UpdateQuality()函数进行修改和添加新代码,只要系统还能正常工作。然而,不要修改Item类或其属性,因为那属于角落里的地精,他会非常愤怒地爆你头,因为他不相信代码共享所有制(如果你愿意,你可以将UpdateQuality方法和Items属性改为静态的,我们会掩护你的)。 31 | 32 | 再次澄清,每种物品的品质不会超过50,然而"Sulfuras"是一个传奇物品,因此它的品质是80且永远不变。 33 | -------------------------------------------------------------------------------- /dart/bin/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:gilded_rose/gilded_rose.dart'; 2 | 3 | main(List args) { 4 | print("OMGHAI!"); 5 | 6 | var items = [ 7 | new Item("+5 Dexterity Vest", 10, 20), 8 | new Item("Aged Brie", 2, 0), 9 | new Item("Elixir of the Mongoose", 5, 7), 10 | new Item("Sulfuras, Hand of Ragnaros", 0, 80), 11 | new Item("Sulfuras, Hand of Ragnaros", -1, 80), 12 | new Item("Backstage passes to a TAFKAL80ETC concert", 15, 20), 13 | new Item("Backstage passes to a TAFKAL80ETC concert", 10, 49), 14 | new Item("Backstage passes to a TAFKAL80ETC concert", 5, 49), 15 | // this conjured item does not work properly yet 16 | new Item("Conjured Mana Cake", 3, 6) 17 | ]; 18 | 19 | GildedRose app = new GildedRose(items); 20 | 21 | int days = 2; 22 | if (args.length > 0) { 23 | days = int.parse(args[0]) + 1; 24 | } 25 | 26 | for (int i = 0; i < days; i++) { 27 | print("-------- day $i --------"); 28 | print("name, sellIn, quality"); 29 | for (var item in items) { 30 | print(item); 31 | } 32 | print(''); 33 | app.updateQuality(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /plantuml/history/06_sulfuras.puml: -------------------------------------------------------------------------------- 1 | @startuml 2 | 3 | skinparam backgroundColor transparent 4 | 5 | start 6 | 7 | if (not "Aged Brie") then (yes) 8 | if (quality > 0) then (yes) 9 | if (not "Sulfuras, Hand of Ragnaros") then (yes) 10 | :lower quality with 1; 11 | else (no) 12 | endif 13 | else (no) 14 | endif 15 | else (no) 16 | if (quality < 50) then (yes) 17 | :increase quality with 1; 18 | else (no) 19 | endif 20 | endif 21 | 22 | if (not "Sulfuras, Hand of Ragnaros") then (yes) 23 | :lower sell in with 1; 24 | else (no) 25 | endif 26 | 27 | if (sell in < 0) then (yes) 28 | if (not "Aged Brie") then (yes) 29 | if (quality > 0) then (yes) 30 | if (not "Sulfuras, Hand of Ragnaros") then (yes) 31 | :lower quality with 1; 32 | else (no) 33 | endif 34 | else (no) 35 | endif 36 | else (no) 37 | if (quality < 50) then (yes) 38 | :increase quality with 1; 39 | else (no) 40 | endif 41 | endif 42 | else (no) 43 | endif 44 | 45 | stop 46 | 47 | @enduml 48 | -------------------------------------------------------------------------------- /go/texttest_fixture.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "strconv" 7 | ) 8 | 9 | func main() { 10 | fmt.Println("OMGHAI!") 11 | 12 | var items = []*Item{ 13 | &Item{"+5 Dexterity Vest", 10, 20}, 14 | &Item{"Aged Brie", 2, 0}, 15 | &Item{"Elixir of the Mongoose", 5, 7}, 16 | &Item{"Sulfuras, Hand of Ragnaros", 0, 80}, 17 | &Item{"Sulfuras, Hand of Ragnaros", -1, 80}, 18 | &Item{"Backstage passes to a TAFKAL80ETC concert", 15, 20}, 19 | &Item{"Backstage passes to a TAFKAL80ETC concert", 10, 49}, 20 | &Item{"Backstage passes to a TAFKAL80ETC concert", 5, 49}, 21 | &Item{"Conjured Mana Cake", 3, 6}, // <-- :O 22 | } 23 | 24 | days := 2 25 | var err error 26 | if len(os.Args) > 1 { 27 | days, err = strconv.Atoi(os.Args[1]) 28 | if err != nil { 29 | fmt.Println(err.Error()) 30 | os.Exit(1) 31 | } 32 | days++ 33 | } 34 | 35 | for day := 0; day < days; day++ { 36 | fmt.Printf("-------- day %d --------\n", day) 37 | fmt.Println("name, sellIn, quality") 38 | for i := 0; i < len(items); i++ { 39 | fmt.Println(items[i]) 40 | } 41 | fmt.Println("") 42 | UpdateQuality(items) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /license.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 @emilybache 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /haskell/gilded-rose.cabal: -------------------------------------------------------------------------------- 1 | name: gilded-rose 2 | version: 0.1.0.0 3 | synopsis: Haskell-port of the gilded rose kata 4 | license: GPL 5 | author: Sven Heyll 6 | maintainer: sven.heyll@gmail.com 7 | category: System 8 | build-type: Simple 9 | cabal-version: >=1.10 10 | 11 | library 12 | exposed-modules: GildedRose 13 | build-depends: base >=4.7 14 | hs-source-dirs: src 15 | default-language: Haskell2010 16 | 17 | executable gilded-rose 18 | main-is: Main.hs 19 | build-depends: gilded-rose, base >=4.7 20 | hs-source-dirs: src 21 | default-language: Haskell2010 22 | other-modules: GildedRose 23 | 24 | test-suite spec 25 | type: exitcode-stdio-1.0 26 | ghc-options: -Wall 27 | hs-source-dirs: test 28 | default-language: Haskell2010 29 | main-is: Spec.hs 30 | other-modules: GildedRoseSpec 31 | build-depends: base >=4.7 32 | , gilded-rose 33 | , hspec 34 | , hspec-expectations 35 | , QuickCheck 36 | -------------------------------------------------------------------------------- /d/src/GildedRoseTextTests.d: -------------------------------------------------------------------------------- 1 | import GildedRose; 2 | 3 | int main() 4 | { 5 | import std.stdio : writefln, writeln; 6 | 7 | Item[] items = [ 8 | Item("+5 Dexterity Vest", 10, 20), 9 | Item("Aged Brie", 2, 0), 10 | Item("Elixir of the Mongoose", 5, 7), 11 | Item("Sulfuras, Hand of Ragnaros", 0, 80), 12 | Item("Sulfuras, Hand of Ragnaros", -1, 80), 13 | Item("Backstage passes to a TAFKAL80ETC concert", 15, 20), 14 | Item("Backstage passes to a TAFKAL80ETC concert", 10, 49), 15 | Item("Backstage passes to a TAFKAL80ETC concert", 5, 49), 16 | // this Conjured item doesn't yet work properly 17 | Item("Conjured Mana Cake", 3, 6), 18 | ]; 19 | 20 | auto app = new GildedRose(items); 21 | 22 | writeln("OMGHAI!"); 23 | 24 | for (int day = 0; day <= 30; day++) 25 | { 26 | writefln!"-------- day %s --------"(day); 27 | writeln("Item(name, sellIn, quality)"); 28 | foreach (item; app.items) 29 | { 30 | writeln(item); 31 | } 32 | writeln; 33 | 34 | app.updateQuality; 35 | } 36 | 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /fsharp-core/GildedRose.ApprovalTests/GildedRose.ApprovalTests.fsproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp2.1 5 | 6 | false 7 | 8 | 9 | 10 | 11 | Always 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | all 21 | runtime; build; native; contentfiles; analyzers 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /php7/fixtures/texttest_fixture.php: -------------------------------------------------------------------------------- 1 | 1) { 27 | $days = (int) $argv[1]; 28 | } 29 | 30 | for ($i = 0; $i < $days; $i++) { 31 | echo("-------- day $i --------\n"); 32 | echo("name, sellIn, quality\n"); 33 | foreach ($items as $item) { 34 | echo $item . PHP_EOL; 35 | } 36 | echo PHP_EOL; 37 | $app->updateQuality(); 38 | } 39 | -------------------------------------------------------------------------------- /C/GildedRoseUnitTests.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | extern "C" { 6 | #include "GildedRose.h" 7 | } 8 | 9 | TEST_GROUP(TestGildedRoseGroup) 10 | { 11 | void setup() { 12 | } 13 | void teardown() { 14 | } 15 | }; 16 | 17 | TEST(TestGildedRoseGroup, FirstTest) 18 | { 19 | Item items[2]; 20 | init_item(items, "Foo", 0, 0); 21 | update_quality(items, 1); 22 | STRCMP_EQUAL("fixme", items[0].name); 23 | } 24 | 25 | void example() 26 | { 27 | Item items[6]; 28 | int last = 0; 29 | 30 | init_item(items + last++, "+5 Dexterity Vest", 10, 20); 31 | init_item(items + last++, "Aged Brie", 2, 0); 32 | init_item(items + last++, "Elixir of the Mongoose", 5, 7); 33 | init_item(items + last++, "Sulfuras, Hand of Ragnaros", 0, 80); 34 | init_item(items + last++, "Backstage passes to a TAFKAL80ETC concert", 15, 20); 35 | init_item(items + last++, "Conjured Mana Cake", 3, 6); 36 | update_quality(items, last); 37 | } 38 | 39 | int 40 | main(int ac, char** av) 41 | { 42 | return CommandLineTestRunner::RunAllTests(ac, av); 43 | } 44 | -------------------------------------------------------------------------------- /Groovy/src/com/gildedrose/TexttestFixture.groovy: -------------------------------------------------------------------------------- 1 | package com.gildedrose 2 | 3 | println("OMGHAI!") 4 | 5 | Item[] items = [ 6 | new Item("+5 Dexterity Vest", 10, 20), 7 | new Item("Aged Brie", 2, 0), 8 | new Item("Elixir of the Mongoose", 5, 7), 9 | new Item("Sulfuras, Hand of Ragnaros", 0, 80), 10 | new Item("Sulfuras, Hand of Ragnaros", -1, 80), 11 | new Item("Backstage passes to a TAFKAL80ETC concert", 15, 20), 12 | new Item("Backstage passes to a TAFKAL80ETC concert", 10, 49), 13 | new Item("Backstage passes to a TAFKAL80ETC concert", 5, 49), 14 | // this conjured item does not work properly yet 15 | new Item("Conjured Mana Cake", 3, 6)] as Item[] 16 | 17 | GildedRose app = new GildedRose(items) 18 | 19 | int days = 2 20 | if (args.length > 0) { 21 | days = Integer.parseInt(args[0]) + 1 22 | } 23 | 24 | for (int i = 0; i < days; i++) { 25 | println("-------- day " + i + " --------") 26 | println("name, sellIn, quality") 27 | for (Item item in items) { 28 | println(item) 29 | } 30 | println "" 31 | app.updateQuality() 32 | } 33 | -------------------------------------------------------------------------------- /Ada/gilded_rose_tests.adb: -------------------------------------------------------------------------------- 1 | with Gilded_Rose; 2 | use Gilded_Rose; 3 | 4 | with Items; 5 | use Items; 6 | 7 | with Ahven; 8 | 9 | with Ada.Strings.Unbounded; 10 | 11 | package body Gilded_Rose_Tests is 12 | procedure Initialize(T : in out Test) is 13 | begin 14 | Set_Name(T, "Gilded_Rose_Test"); 15 | Ahven.Framework.Add_Test_Routine(T, Test_Gilded_Rose'Access, "Foo"); 16 | end Initialize; 17 | 18 | procedure Test_Gilded_Rose is 19 | Things : Item_Vecs.Vector; 20 | begin 21 | Things.Append(New_Item => 22 | (Name => SU.To_Unbounded_String("Foo"), 23 | Sell_In => 0, 24 | Quality => 0)); 25 | declare 26 | App : Gilded_Rose.Gilded_Rose := (Items => Things); 27 | 28 | package SU renames Ada.Strings.Unbounded; 29 | procedure Assert_Eq_Unbounded_String is 30 | new Ahven.Assert_Equal(Data_Type => SU.Unbounded_String, Image => SU.To_String); 31 | begin 32 | Update_Quality(App); 33 | Assert_Eq_Unbounded_String(Actual => App.Items(Item_Vecs.First(App.Items)).Name, 34 | Expected => SU.To_Unbounded_String("fixme"), 35 | Message => "fixme"); 36 | end; 37 | end; 38 | end Gilded_Rose_Tests; 39 | -------------------------------------------------------------------------------- /swift/Sources/GildedRoseApp/main.swift: -------------------------------------------------------------------------------- 1 | import GildedRose 2 | 3 | let items = [ 4 | Item(name: "+5 Dexterity Vest", sellIn: 10, quality: 20), 5 | Item(name: "Aged Brie", sellIn: 2, quality: 0), 6 | Item(name: "Elixir of the Mongoose", sellIn: 5, quality: 7), 7 | Item(name: "Sulfuras, Hand of Ragnaros", sellIn: 0, quality: 80), 8 | Item(name: "Sulfuras, Hand of Ragnaros", sellIn: -1, quality: 80), 9 | Item(name: "Backstage passes to a TAFKAL80ETC concert", sellIn: 15, quality: 20), 10 | Item(name: "Backstage passes to a TAFKAL80ETC concert", sellIn: 10, quality: 49), 11 | Item(name: "Backstage passes to a TAFKAL80ETC concert", sellIn: 5, quality: 49), 12 | // this conjured item does not work properly yet 13 | Item(name: "Conjured Mana Cake", sellIn: 3, quality: 6)] 14 | 15 | let app = GildedRose(items: items); 16 | 17 | var days = 2; 18 | if (CommandLine.argc > 1) { 19 | days = Int(CommandLine.arguments[1])! + 1 20 | } 21 | 22 | for i in 0.. 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.13) 2 | project(gilded-rose-refactoring-kata-cpp) 3 | 4 | # Load FetchContent module. 5 | include(FetchContent) 6 | 7 | # Declare GoogleTest as the content to fetch 8 | FetchContent_Declare( 9 | googletest 10 | GIT_REPOSITORY https://github.com/google/googletest.git 11 | GIT_TAG release-1.8.1 12 | ) 13 | 14 | # Fetch GoogleTest amd make build scripts available 15 | if (NOT googletest_POPULATED) 16 | FetchContent_Populate(googletest) 17 | endif() 18 | 19 | #set(gtest_force_shared_crt OFF CACHE BOOL "" FORCE) 20 | # Force Google Test to link the C/C++ runtimes dynamically when 21 | # building on Visual Studio 22 | # Link: 23 | # * https://github.com/google/googletest/tree/release-1.8.1/googletest#visual-studio-dynamic-vs-static-runtimes 24 | if (MSVC) 25 | set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) 26 | endif() 27 | 28 | # Bring the populated content into the build 29 | add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR}) 30 | 31 | # uncomment this line to enable coverage measurements using gcov 32 | # set(CMAKE_CXX_FLAGS "--coverage") 33 | 34 | enable_testing() 35 | add_subdirectory(src) 36 | add_subdirectory(lib) 37 | add_subdirectory(test) 38 | -------------------------------------------------------------------------------- /Kotlin/src/test/kotlin/com/gildedrose/TexttestFixture.kt: -------------------------------------------------------------------------------- 1 | package com.gildedrose 2 | 3 | fun main(args: Array) { 4 | 5 | println("OMGHAI!") 6 | 7 | val items = arrayOf(Item("+5 Dexterity Vest", 10, 20), // 8 | Item("Aged Brie", 2, 0), // 9 | Item("Elixir of the Mongoose", 5, 7), // 10 | Item("Sulfuras, Hand of Ragnaros", 0, 80), // 11 | Item("Sulfuras, Hand of Ragnaros", -1, 80), 12 | Item("Backstage passes to a TAFKAL80ETC concert", 15, 20), 13 | Item("Backstage passes to a TAFKAL80ETC concert", 10, 49), 14 | Item("Backstage passes to a TAFKAL80ETC concert", 5, 49), 15 | // this conjured item does not work properly yet 16 | Item("Conjured Mana Cake", 3, 6)) 17 | 18 | val app = GildedRose(items) 19 | 20 | var days = 2 21 | if (args.size > 0) { 22 | days = Integer.parseInt(args[0]) + 1 23 | } 24 | 25 | for (i in 0..days - 1) { 26 | println("-------- day $i --------") 27 | println("name, sellIn, quality") 28 | for (item in items) { 29 | println(item) 30 | } 31 | println() 32 | app.updateQuality() 33 | } 34 | 35 | 36 | } 37 | -------------------------------------------------------------------------------- /scala/src/test/scala/com/gildedrose/TexttestFixture.scala: -------------------------------------------------------------------------------- 1 | package com.gildedrose 2 | 3 | object TexttestFixture { 4 | def main(args: Array[String]): Unit = { 5 | val items = Array[Item]( 6 | new Item("+5 Dexterity Vest", 10, 20), 7 | new Item("Aged Brie", 2, 0), 8 | new Item("Elixir of the Mongoose", 5, 7), 9 | new Item("Sulfuras, Hand of Ragnaros", 0, 80), 10 | new Item("Sulfuras, Hand of Ragnaros", -1, 80), 11 | new Item("Backstage passes to a TAFKAL80ETC concert", 15, 20), 12 | new Item("Backstage passes to a TAFKAL80ETC concert", 10, 49), 13 | new Item("Backstage passes to a TAFKAL80ETC concert", 5, 49), 14 | // this conjured item does not work properly yet 15 | new Item("Conjured Mana Cake", 3, 6) 16 | ) 17 | val app = new GildedRose(items) 18 | val days = if (args.length > 0) args(0).toInt + 1 else 2 19 | for (i <- 0 until days) { 20 | System.out.println("-------- day " + i + " --------") 21 | System.out.println("name, sellIn, quality") 22 | for (item <- items) { 23 | System.out.println(item.name + ", " + item.sellIn + ", " + item.quality) 24 | } 25 | System.out.println() 26 | app.updateQuality() 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /ruby/texttest_fixture.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/ruby -w 2 | 3 | require File.join(File.dirname(__FILE__), 'gilded_rose') 4 | 5 | puts "OMGHAI!" 6 | items = [ 7 | Item.new(name="+5 Dexterity Vest", sell_in=10, quality=20), 8 | Item.new(name="Aged Brie", sell_in=2, quality=0), 9 | Item.new(name="Elixir of the Mongoose", sell_in=5, quality=7), 10 | Item.new(name="Sulfuras, Hand of Ragnaros", sell_in=0, quality=80), 11 | Item.new(name="Sulfuras, Hand of Ragnaros", sell_in=-1, quality=80), 12 | Item.new(name="Backstage passes to a TAFKAL80ETC concert", sell_in=15, quality=20), 13 | Item.new(name="Backstage passes to a TAFKAL80ETC concert", sell_in=10, quality=49), 14 | Item.new(name="Backstage passes to a TAFKAL80ETC concert", sell_in=5, quality=49), 15 | # This Conjured item does not work properly yet 16 | Item.new(name="Conjured Mana Cake", sell_in=3, quality=6), # <-- :O 17 | ] 18 | 19 | days = 2 20 | if ARGV.size > 0 21 | days = ARGV[0].to_i + 1 22 | end 23 | 24 | gilded_rose = GildedRose.new items 25 | (0...days).each do |day| 26 | puts "-------- day #{day} --------" 27 | puts "name, sellIn, quality" 28 | items.each do |item| 29 | puts item 30 | end 31 | puts "" 32 | gilded_rose.update_quality 33 | end 34 | -------------------------------------------------------------------------------- /rust/src/main.rs: -------------------------------------------------------------------------------- 1 | 2 | mod gildedrose; 3 | 4 | use gildedrose::{Item, GildedRose}; 5 | 6 | fn main() { 7 | let items = vec![ 8 | Item::new(String::from("+5 Dexterity Vest"), 10, 20), 9 | Item::new(String::from("Aged Brie"), 2, 0), 10 | Item::new(String::from("Elixir of the Mongoose"), 5, 7), 11 | Item::new(String::from("Sulfuras, Hand of Ragnaros"), 0, 80), 12 | Item::new(String::from("Sulfuras, Hand of Ragnaros"), -1, 80), 13 | Item::new(String::from("Backstage passes to a TAFKAL80ETC concert"), 15, 20), 14 | Item::new(String::from("Backstage passes to a TAFKAL80ETC concert"), 10, 49), 15 | Item::new(String::from("Backstage passes to a TAFKAL80ETC concert"), 5, 49), 16 | // this conjured item does not work properly yet 17 | Item::new(String::from("Conjured Mana Cake"), 3, 6) 18 | ]; 19 | let mut rose = GildedRose::new(items); 20 | 21 | println!("OMGHAI!"); 22 | for i in (0..30) { 23 | println!("-------- day {} --------", i); 24 | println!("name, sellIn, quality"); 25 | for item in &rose.items { 26 | println!("{}, {}, {}", item.name, item.sell_in, item.quality); 27 | } 28 | println!(""); 29 | rose.update_quality(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /python/texttest_fixture.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from __future__ import print_function 3 | 4 | from gilded_rose import * 5 | 6 | if __name__ == "__main__": 7 | print ("OMGHAI!") 8 | items = [ 9 | Item(name="+5 Dexterity Vest", sell_in=10, quality=20), 10 | Item(name="Aged Brie", sell_in=2, quality=0), 11 | Item(name="Elixir of the Mongoose", sell_in=5, quality=7), 12 | Item(name="Sulfuras, Hand of Ragnaros", sell_in=0, quality=80), 13 | Item(name="Sulfuras, Hand of Ragnaros", sell_in=-1, quality=80), 14 | Item(name="Backstage passes to a TAFKAL80ETC concert", sell_in=15, quality=20), 15 | Item(name="Backstage passes to a TAFKAL80ETC concert", sell_in=10, quality=49), 16 | Item(name="Backstage passes to a TAFKAL80ETC concert", sell_in=5, quality=49), 17 | Item(name="Conjured Mana Cake", sell_in=3, quality=6), # <-- :O 18 | ] 19 | 20 | days = 2 21 | import sys 22 | if len(sys.argv) > 1: 23 | days = int(sys.argv[1]) + 1 24 | for day in range(days): 25 | print("-------- day %s --------" % day) 26 | print("name, sellIn, quality") 27 | for item in items: 28 | print(item) 29 | print("") 30 | GildedRose(items).update_quality() 31 | -------------------------------------------------------------------------------- /plpgsql/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM postgres:12.1 as base 2 | WORKDIR /app 3 | 4 | ENV PGHOST=localhost 5 | ENV PGDATABASE=kata 6 | ENV PGPASSWORD=admin 7 | ENV PGUSER=postgres 8 | ENV POSTGRES_PASSWORD=admin 9 | ENV PGDATA /var/lib/postgresql/data_local 10 | 11 | RUN mkdir -p "$PGDATA" && chown -R postgres:postgres "$PGDATA" && chmod 777 "$PGDATA" 12 | 13 | ADD ./*.sh /app/ 14 | ADD ./src/item.sql /app/src/ 15 | ADD ./src/new_item.sql /app/src/ 16 | 17 | # PGUNIT 18 | FROM base as pgunit 19 | 20 | RUN apt-get update \ 21 | && apt-get install -y --no-install-recommends ca-certificates wget \ 22 | && rm -rf /var/lib/apt/lists/* 23 | 24 | ADD ./pgunit/initialize.sh /app/ 25 | ADD ./pgunit/*.sql /app/ 26 | RUN chmod +x ./*.sh \ 27 | && ./initializeDocker.sh 28 | 29 | # PGTAP 30 | FROM base as pgtap 31 | 32 | RUN apt-get update \ 33 | && apt-get install -y --no-install-recommends ca-certificates build-essential git-core libv8-dev curl postgresql-server-dev-12 \ 34 | && rm -rf /var/lib/apt/lists/* 35 | 36 | RUN mkdir -p /tmp/pgtap \ 37 | && cd /tmp/pgtap \ 38 | && git clone https://github.com/theory/pgtap.git /tmp/pgtap \ 39 | && make \ 40 | && make install \ 41 | && cpan TAP::Parser::SourceHandler::pgTAP 42 | 43 | ADD ./pgtap/initialize.sh /app/ 44 | RUN chmod +x ./*.sh \ 45 | && ./initializeDocker.sh 46 | -------------------------------------------------------------------------------- /cpp/test/cpp_texttest/GildedRoseTextTests.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include "GildedRose.h" 3 | 4 | int 5 | print_item(Item *item) 6 | { 7 | return printf("%s, %d, %d\n", item->name.c_str(), item->sellIn, item->quality); 8 | } 9 | 10 | int main() 11 | { 12 | vector items; 13 | 14 | items.emplace_back("+5 Dexterity Vest", 10, 20); 15 | items.emplace_back("Aged Brie", 2, 0); 16 | items.emplace_back("Elixir of the Mongoose", 5, 7); 17 | items.emplace_back("Sulfuras, Hand of Ragnaros", 0, 80); 18 | items.emplace_back("Sulfuras, Hand of Ragnaros", -1, 80); 19 | items.emplace_back("Backstage passes to a TAFKAL80ETC concert", 15, 20); 20 | items.emplace_back("Backstage passes to a TAFKAL80ETC concert", 10, 49); 21 | items.emplace_back("Backstage passes to a TAFKAL80ETC concert", 5, 49); 22 | 23 | // this Conjured item doesn't yet work properly 24 | items.emplace_back("Conjured Mana Cake", 3, 6); 25 | 26 | puts("OMGHAI!"); 27 | 28 | GildedRose app(items); 29 | 30 | for (int day = 0; day <= 30; day++) 31 | { 32 | printf("-------- day %d --------\n", day); 33 | printf("name, sellIn, quality\n"); 34 | for (auto & item : items) 35 | { 36 | print_item(&item); 37 | } 38 | printf("\n"); 39 | app.updateQuality(); 40 | } 41 | return 0; 42 | } 43 | 44 | 45 | -------------------------------------------------------------------------------- /scheme/texttest-fixture.scm: -------------------------------------------------------------------------------- 1 | (include "gilded-rose.scm") 2 | 3 | (display "OMGHAI!") 4 | (newline) 5 | 6 | (let ((items (list (make-item "+5 Dexterity Vest" 10 20) 7 | (make-item "Aged Brie" 2 0) 8 | (make-item "Elixir of the Mongoose" 5 7) 9 | (make-item "Sulfuras, Hand of Ragnaros" 0 80) 10 | (make-item "Sulfuras, Hand of Ragnaros" -1 80) 11 | (make-item "Backstage passes to a TAFKAL80ETC concert" 15 20) 12 | (make-item "Backstage passes to a TAFKAL80ETC concert" 10 49) 13 | (make-item "Backstage passes to a TAFKAL80ETC concert" 5 49) 14 | ;; this conjured item does not work properly yet 15 | (make-item "Conjured Mana Cake" 3 6))) 16 | (days 2)) 17 | 18 | (define (loop day) 19 | (cond ((< day days) 20 | (display (string-append "-------- day " (number->string day) " --------")) 21 | (newline) 22 | (display "name, sell-in, quality") 23 | (newline) 24 | (for-each 25 | (lambda (item) 26 | (display (item-to-string item)) 27 | (newline)) 28 | items) 29 | (newline) 30 | (update-quality items) 31 | (loop (+ day 1))))) 32 | (loop 0)) 33 | -------------------------------------------------------------------------------- /C/GildedRoseTextTests.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "GildedRose.h" 3 | 4 | int 5 | print_item(Item *item) 6 | { 7 | return printf("%s, %d, %d\n", item->name, item->sellIn, item->quality); 8 | } 9 | 10 | int main() 11 | { 12 | Item items[9]; 13 | int last = 0; 14 | int day; 15 | int index; 16 | 17 | init_item(items + last++, "+5 Dexterity Vest", 10, 20); 18 | init_item(items + last++, "Aged Brie", 2, 0); 19 | init_item(items + last++, "Elixir of the Mongoose", 5, 7); 20 | init_item(items + last++, "Sulfuras, Hand of Ragnaros", 0, 80); 21 | init_item(items + last++, "Sulfuras, Hand of Ragnaros", -1, 80); 22 | init_item(items + last++, "Backstage passes to a TAFKAL80ETC concert", 15, 20); 23 | init_item(items + last++, "Backstage passes to a TAFKAL80ETC concert", 10, 49); 24 | init_item(items + last++, "Backstage passes to a TAFKAL80ETC concert", 5, 49); 25 | // this Conjured item doesn't yet work properly 26 | init_item(items + last++, "Conjured Mana Cake", 3, 6); 27 | 28 | puts("OMGHAI!"); 29 | 30 | for (day = 0; day <= 30; day++) 31 | { 32 | printf("-------- day %d --------\n", day); 33 | printf("name, sellIn, quality\n"); 34 | for(index = 0; index < last; index++) { 35 | print_item(items + index); 36 | } 37 | 38 | printf("\n"); 39 | 40 | update_quality(items, last); 41 | } 42 | return 0; 43 | } 44 | -------------------------------------------------------------------------------- /c99/GildedRoseTextTests.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "GildedRose.h" 3 | 4 | int 5 | print_item(Item *item) 6 | { 7 | return printf("%s, %d, %d\n", item->name, item->sellIn, item->quality); 8 | } 9 | 10 | int main() 11 | { 12 | Item items[9]; 13 | int last = 0; 14 | int day; 15 | int index; 16 | 17 | init_item(items + last++, "+5 Dexterity Vest", 10, 20); 18 | init_item(items + last++, "Aged Brie", 2, 0); 19 | init_item(items + last++, "Elixir of the Mongoose", 5, 7); 20 | init_item(items + last++, "Sulfuras, Hand of Ragnaros", 0, 80); 21 | init_item(items + last++, "Sulfuras, Hand of Ragnaros", -1, 80); 22 | init_item(items + last++, "Backstage passes to a TAFKAL80ETC concert", 15, 20); 23 | init_item(items + last++, "Backstage passes to a TAFKAL80ETC concert", 10, 49); 24 | init_item(items + last++, "Backstage passes to a TAFKAL80ETC concert", 5, 49); 25 | // this Conjured item doesn't yet work properly 26 | init_item(items + last++, "Conjured Mana Cake", 3, 6); 27 | 28 | puts("OMGHAI!"); 29 | 30 | for (day = 0; day <= 30; day++) 31 | { 32 | printf("-------- day %d --------\n", day); 33 | printf("name, sellIn, quality\n"); 34 | for(index = 0; index < last; index++) { 35 | print_item(items + index); 36 | } 37 | 38 | printf("\n"); 39 | 40 | update_quality(items, last); 41 | } 42 | return 0; 43 | } 44 | -------------------------------------------------------------------------------- /plantuml/readme.md: -------------------------------------------------------------------------------- 1 | # PlantUML 2 | This UML refactoring exercise is aimed at less technical people like analysts, testers and other non-programmers. The key takeaway message is clarifying the need for continuous refactoring to people who do not code on a daily basis. 3 | 4 | ## Running and rendering 5 | If you want to get started quickly, just copy the contents of `plantuml/gilded-rose.puml`, and paste it in https://www.planttext.com/ 6 | 7 | Several alternatives are available to render PlantUML, see https://plantuml.com/running. 8 | 9 | ## Syntax 10 | For the syntax of activity diagrams in PlantUML, please refer to https://plantuml.com/activity-diagram-beta 11 | 12 | ## Workshop 13 | You can run this exercise as a workshop. 14 | 15 | During this workshop, you start off with a presentation explaining the domain, while filling out the testcases found under `plantuml/workshop`. After that, participants are invited to refactor the UML Activity Diagram, using the examples that were discovered during the presentation. 16 | [The google slides can be found here](https://docs.google.com/presentation/d/1kkRnVQjZELcfuGoFXaiSY_HxbO4lPQnSgHRGQZIH2nU/edit?usp=sharing). 17 | 18 | ## History 19 | If you want to illustrate how this activity diagram got to this state, you can show the requirements and the files under the /history directory. These individual files show the evolution of the activity diagram. 20 | 21 | ## Original state 22 | ![The original activity diagram](./gilded-rose.png) 23 | -------------------------------------------------------------------------------- /Java/src/test/java/com/gildedrose/TexttestFixture.java: -------------------------------------------------------------------------------- 1 | package com.gildedrose; 2 | 3 | public class TexttestFixture { 4 | public static void main(String[] args) { 5 | System.out.println("OMGHAI!"); 6 | 7 | Item[] items = new Item[] { 8 | new Item("+5 Dexterity Vest", 10, 20), // 9 | new Item("Aged Brie", 2, 0), // 10 | new Item("Elixir of the Mongoose", 5, 7), // 11 | new Item("Sulfuras, Hand of Ragnaros", 0, 80), // 12 | new Item("Sulfuras, Hand of Ragnaros", -1, 80), 13 | new Item("Backstage passes to a TAFKAL80ETC concert", 15, 20), 14 | new Item("Backstage passes to a TAFKAL80ETC concert", 10, 49), 15 | new Item("Backstage passes to a TAFKAL80ETC concert", 5, 49), 16 | // this conjured item does not work properly yet 17 | new Item("Conjured Mana Cake", 3, 6) }; 18 | 19 | GildedRose app = new GildedRose(items); 20 | 21 | int days = 2; 22 | if (args.length > 0) { 23 | days = Integer.parseInt(args[0]) + 1; 24 | } 25 | 26 | for (int i = 0; i < days; i++) { 27 | System.out.println("-------- day " + i + " --------"); 28 | System.out.println("name, sellIn, quality"); 29 | for (Item item : items) { 30 | System.out.println(item); 31 | } 32 | System.out.println(); 33 | app.updateQuality(); 34 | } 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /Java-Spock/src/main/java/com/gildedrose/TexttestFixture.java: -------------------------------------------------------------------------------- 1 | package com.gildedrose; 2 | 3 | public class TexttestFixture { 4 | public static void main(String[] args) { 5 | System.out.println("OMGHAI!"); 6 | 7 | Item[] items = new Item[] { 8 | new Item("+5 Dexterity Vest", 10, 20), // 9 | new Item("Aged Brie", 2, 0), // 10 | new Item("Elixir of the Mongoose", 5, 7), // 11 | new Item("Sulfuras, Hand of Ragnaros", 0, 80), // 12 | new Item("Sulfuras, Hand of Ragnaros", -1, 80), 13 | new Item("Backstage passes to a TAFKAL80ETC concert", 15, 20), 14 | new Item("Backstage passes to a TAFKAL80ETC concert", 10, 49), 15 | new Item("Backstage passes to a TAFKAL80ETC concert", 5, 49), 16 | // this conjured item does not work properly yet 17 | new Item("Conjured Mana Cake", 3, 6) }; 18 | 19 | GildedRose app = new GildedRose(items); 20 | 21 | int days = 2; 22 | if (args.length > 0) { 23 | days = Integer.parseInt(args[0]) + 1; 24 | } 25 | 26 | for (int i = 0; i < days; i++) { 27 | System.out.println("-------- day " + i + " --------"); 28 | System.out.println("name, sellIn, quality"); 29 | for (Item item : items) { 30 | System.out.println(item); 31 | } 32 | System.out.println(); 33 | app.updateQuality(); 34 | } 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /csharp/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("csharp")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("csharp")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("176c0214-9136-4079-8dab-11d7420c3881")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /C/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for building the kata file with the Google Testing Framework 2 | # 3 | # SYNOPSIS: 4 | # 5 | # make [all] - makes everything. 6 | # make TARGET - makes the given target. 7 | # make clean - removes all files generated by make. 8 | 9 | # Please tweak the following variable definitions as needed by your 10 | # project. 11 | 12 | # Points to the root of CppUTest, relative to where this file is. 13 | # Remember to tweak this if you move this file. 14 | CPPUTEST_HOME = CppUTest 15 | 16 | # Where to find user code. 17 | USER_DIR = . 18 | 19 | # Flags passed to the preprocessor. 20 | CPPFLAGS += -I$(CPPUTEST_HOME)/include 21 | 22 | # Flags passed to the C++ compiler. 23 | CFLAGS += -g -Wall -Wextra 24 | 25 | LD_LIBRARIES = -L$(CPPUTEST_HOME)/lib -lCppUTest 26 | 27 | # All tests produced by this Makefile. Remember to add new tests you 28 | # created to the list. 29 | TESTS = GildedRoseUnitTests 30 | 31 | TEXTTESTS = GildedRoseTextTests 32 | 33 | # House-keeping build targets. 34 | 35 | all : $(TESTS) $(TEXTTESTS) 36 | 37 | GildedRose.o : $(USER_DIR)/GildedRose.c 38 | 39 | GildedRoseUnitTests : $(USER_DIR)/GildedRoseUnitTests.cc GildedRose.o 40 | $(CXX) $(CPPFLAGS) $(CFLAGS) -o $@ $(USER_DIR)/GildedRoseUnitTests.cc GildedRose.o $(LD_LIBRARIES) 41 | 42 | GildedRoseTextTests.o : $(USER_DIR)/GildedRoseTextTests.c 43 | 44 | GildedRoseTextTests : GildedRoseTextTests.o GildedRose.o 45 | $(CC) $^ -o $@ 46 | 47 | clean : 48 | rm -f $(TESTS) $(TEXTTESTS) *.o *~ 49 | 50 | check-syntax: 51 | gcc $(CPPFLAGS) -o /dev/null -S ${CHK_SOURCES} 52 | -------------------------------------------------------------------------------- /php7/README.md: -------------------------------------------------------------------------------- 1 | Requirements 2 | ------------ 3 | 4 | **PHP 7:** 5 | 6 | This is usually bundled with your operating system, or fetchable using a package manager like `apt` or `homebrew`. 7 | 8 | Windows users can find the latest version here: https://windows.php.net/download#php-7.3 9 | 10 | If you want to compile from source code, that can be found here: https://www.php.net/downloads.php 11 | 12 | **Composer:** 13 | 14 | Composer is PHP's main package and dependency management tool. 15 | 16 | It can be downloaded here: https://getcomposer.org/download/ 17 | 18 | Getting Started 19 | --------------- 20 | 21 | To begin the kata, install the dependencies and run `phpunit`: 22 | 23 | ``` 24 | cd php7 25 | composer install 26 | vendor/bin/phpunit 27 | ``` 28 | 29 | If the "install" command does not work, try running `composer update` instead. 30 | This will tell composer that it has permission to look for a newer version of 31 | its dependencies. 32 | 33 | If things are still not cooperating, you can try this extreme approach: 34 | 35 | ``` 36 | composer remove phpunit/phpunit 37 | composer require phpunit/phpunit 38 | ``` 39 | 40 | To exercise the code outside of phpunit, for example to visually confirm that it is working, 41 | use the `texttest_fixture` script: 42 | 43 | ``` 44 | php fixtures/texttest_fixture.php 45 | ``` 46 | 47 | Tips 48 | ---- 49 | 50 | PHPUnit has a very thorough reference manual. It would be particularly useful to explore the 51 | [Data Providers](https://phpunit.readthedocs.io/en/8.1/writing-tests-for-phpunit.html#data-providers) section. 52 | -------------------------------------------------------------------------------- /fsharp/GildedRose.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.40629.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "GildedRose", "GildedRose\GildedRose.fsproj", "{2660EF56-B4C1-4DCF-B106-278211BD26C6}" 7 | EndProject 8 | Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "GildedRose.Tests", "GildedRose.Tests\GildedRose.Tests.fsproj", "{9F9D20E1-CFC0-442C-870A-76E5ABF0E7FE}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Release|Any CPU = Release|Any CPU 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {2660EF56-B4C1-4DCF-B106-278211BD26C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {2660EF56-B4C1-4DCF-B106-278211BD26C6}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {2660EF56-B4C1-4DCF-B106-278211BD26C6}.Release|Any CPU.ActiveCfg = Release|Any CPU 19 | {2660EF56-B4C1-4DCF-B106-278211BD26C6}.Release|Any CPU.Build.0 = Release|Any CPU 20 | {9F9D20E1-CFC0-442C-870A-76E5ABF0E7FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {9F9D20E1-CFC0-442C-870A-76E5ABF0E7FE}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {9F9D20E1-CFC0-442C-870A-76E5ABF0E7FE}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {9F9D20E1-CFC0-442C-870A-76E5ABF0E7FE}.Release|Any CPU.Build.0 = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /haskell/src/Main.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import System.Environment 4 | import GildedRose 5 | 6 | 7 | main :: IO () 8 | main = do 9 | putStrLn "OMGHAI!" 10 | 11 | let inventoriesWithDay = inventories `zip` [0..] 12 | inventories = iterate updateQuality initialInventory 13 | 14 | numberOfDays <- daysFromArg 15 | mapM_ printUpdate (take numberOfDays inventoriesWithDay) 16 | 17 | where 18 | printUpdate :: (GildedRose, Int) -> IO () 19 | printUpdate (items, day) = do 20 | putStrLn ("-------- day " ++ show day ++ " --------") 21 | putStrLn "name, sellIn, quality" 22 | mapM_ (putStrLn . show) items 23 | putStrLn "" 24 | 25 | daysFromArg :: IO Int 26 | daysFromArg = do 27 | args <- getArgs 28 | return $ if length args > 0 29 | then read (head args) 30 | else 20 31 | 32 | initialInventory :: GildedRose 33 | initialInventory = 34 | [ Item "+5 Dexterity Vest" 10 20 35 | , Item "Aged Brie" 2 0 36 | , Item "Elixir of the Mongoose" 5 7 37 | , Item "Sulfuras, Hand of Ragnaros" 0 80 38 | , Item "Sulfuras, Hand of Ragnaros" (-1) 80 39 | , Item "Backstage passes to a TAFKAL80ETC concert" 15 20 40 | , Item "Backstage passes to a TAFKAL80ETC concert" 10 49 41 | , Item "Backstage passes to a TAFKAL80ETC concert" 5 49 42 | -- this conjured item does not work properly yet 43 | , Item "Conjured Mana Cake" 3 6 44 | ] 45 | -------------------------------------------------------------------------------- /Java/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 4.0.0 7 | 8 | com.gildedrose 9 | gilded-rose-kata 10 | 0.0.1-SNAPSHOT 11 | 12 | 13 | 1.8 14 | 5.6.2 15 | 3.0.0-M4 16 | 17 | 18 | 19 | 20 | org.junit.jupiter 21 | junit-jupiter 22 | ${junit.jupiter.version} 23 | test 24 | 25 | 26 | 27 | 28 | 29 | 30 | maven-compiler-plugin 31 | 32 | ${java.version} 33 | ${java.version} 34 | 35 | 36 | 37 | maven-surefire-plugin 38 | ${maven.maven-surefire-plugin.version} 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /go/gilded-rose.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type Item struct { 4 | name string 5 | sellIn, quality int 6 | } 7 | 8 | func UpdateQuality(items []*Item) { 9 | for i := 0; i < len(items); i++ { 10 | 11 | if items[i].name != "Aged Brie" && items[i].name != "Backstage passes to a TAFKAL80ETC concert" { 12 | if items[i].quality > 0 { 13 | if items[i].name != "Sulfuras, Hand of Ragnaros" { 14 | items[i].quality = items[i].quality - 1 15 | } 16 | } 17 | } else { 18 | if items[i].quality < 50 { 19 | items[i].quality = items[i].quality + 1 20 | if items[i].name == "Backstage passes to a TAFKAL80ETC concert" { 21 | if items[i].sellIn < 11 { 22 | if items[i].quality < 50 { 23 | items[i].quality = items[i].quality + 1 24 | } 25 | } 26 | if items[i].sellIn < 6 { 27 | if items[i].quality < 50 { 28 | items[i].quality = items[i].quality + 1 29 | } 30 | } 31 | } 32 | } 33 | } 34 | 35 | if items[i].name != "Sulfuras, Hand of Ragnaros" { 36 | items[i].sellIn = items[i].sellIn - 1 37 | } 38 | 39 | if items[i].sellIn < 0 { 40 | if items[i].name != "Aged Brie" { 41 | if items[i].name != "Backstage passes to a TAFKAL80ETC concert" { 42 | if items[i].quality > 0 { 43 | if items[i].name != "Sulfuras, Hand of Ragnaros" { 44 | items[i].quality = items[i].quality - 1 45 | } 46 | } 47 | } else { 48 | items[i].quality = items[i].quality - items[i].quality 49 | } 50 | } else { 51 | if items[i].quality < 50 { 52 | items[i].quality = items[i].quality + 1 53 | } 54 | } 55 | } 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /scheme/assert.scm: -------------------------------------------------------------------------------- 1 | ;;; 2 | ;;; Unit test framework for Scheme 3 | ;;; Copyright (c) 2018, Peter Kofler, http://www.code-cop.org/ 4 | ;;; BSD licensed. 5 | ;;; 6 | ;;; Non S5RS used functions: 7 | ;;; * (error) from R6RS 8 | ;;; 9 | 10 | ;; SchemeUnit from http://c2.com/cgi/wiki?SchemeUnit 11 | 12 | (define (fail msg) 13 | (error (string-append "AssertionError" ": " msg))) 14 | 15 | (define (check msg condition) 16 | (if (not condition) 17 | (fail msg) 18 | #t)) 19 | 20 | (define (assert msg condition) 21 | (lambda () (check msg condition))) 22 | 23 | ;; extensions 24 | 25 | ;; private 26 | (define (make-string-message prefix to-string expected actual) 27 | (make-message prefix 28 | (to-string expected) 29 | (to-string actual))) 30 | 31 | ;; private 32 | (define (make-message prefix expected actual) 33 | (string-append prefix "expected:<" expected "> but was:<" actual ">")) 34 | 35 | (define (assert-equal to-string eq-op expected actual) 36 | (assert (make-string-message "" to-string expected actual) 37 | (eq-op expected actual))) 38 | 39 | (define (assert= expected actual) 40 | (assert-equal number->string = expected actual)) 41 | 42 | (define (assert-string= expected actual) 43 | (assert-equal values string=? expected actual)) 44 | 45 | ;; private 46 | (define (test-case-name name) 47 | (display name) 48 | (display " ... ")) 49 | 50 | ;; private 51 | (define (test-case-success) 52 | (display "OK") 53 | (newline)) 54 | 55 | (define (test-case name . assertions) 56 | (test-case-name name) 57 | (for-each (lambda (a) (a)) assertions) 58 | (test-case-success)) 59 | -------------------------------------------------------------------------------- /perl6/lib/GildedRose.pm6: -------------------------------------------------------------------------------- 1 | use v6; 2 | 3 | use Item; 4 | 5 | class GildedRose { 6 | has Item @.items; 7 | 8 | method update_quality { 9 | for @!items -> $item { 10 | if ($item.name ne 'Aged Brie' && $item.name ne 'Backstage passes to a TAFKAL80ETC concert') { 11 | if ( $item.quality > 0 ) { 12 | if ( $item.name ne 'Sulfuras, Hand of Ragnaros' ) { 13 | $item.quality = $item.quality - 1; 14 | } 15 | } 16 | } 17 | else { 18 | if ( $item.quality < 50 ) { 19 | $item.quality = $item.quality + 1; 20 | 21 | if ( $item.name eq 'Backstage passes to a TAFKAL80ETC concert' ) 22 | { 23 | if ( $item.sell_in < 11 ) { 24 | if ( $item.quality < 50 ) { 25 | $item.quality = $item.quality + 1; 26 | } 27 | } 28 | 29 | if ( $item.sell_in < 6 ) { 30 | if ( $item.quality < 50 ) { 31 | $item.quality = $item.quality + 1; 32 | } 33 | } 34 | } 35 | } 36 | } 37 | 38 | if ( $item.name ne 'Sulfuras, Hand of Ragnaros' ) { 39 | $item.sell_in = $item.sell_in - 1; 40 | } 41 | 42 | if ( $item.sell_in < 0 ) { 43 | if ( $item.name ne 'Aged Brie' ) { 44 | if ( $item.name ne 45 | 'Backstage passes to a TAFKAL80ETC concert' ) 46 | { 47 | if ( $item.quality > 0 ) { 48 | if ( $item.name ne 'Sulfuras, Hand of Ragnaros' ) { 49 | $item.quality = $item.quality - 1; 50 | } 51 | } 52 | } 53 | else { 54 | $item.quality = $item.quality - $item.quality; 55 | } 56 | } 57 | else { 58 | if ( $item.quality < 50 ) { 59 | $item.quality = $item.quality + 1; 60 | } 61 | } 62 | } 63 | } 64 | return; 65 | } 66 | }; 67 | -------------------------------------------------------------------------------- /sql/code/update_quality.sql: -------------------------------------------------------------------------------- 1 | UPDATE item 2 | SET 3 | quality = quality - 1 4 | WHERE 1=1 5 | AND ( name <> 'Aged Brie' AND name <> 'Backstage passes to a TAFKAL80ETC concert') 6 | AND quality > 0 7 | AND name <> 'Sulfuras, Hand of Ragnaros' 8 | ; 9 | 10 | UPDATE item 11 | SET 12 | quality = quality + 1 13 | WHERE 1=1 14 | AND NOT ( name <> 'Aged Brie' AND name <> 'Backstage passes to a TAFKAL80ETC concert') 15 | AND quality < 50 16 | AND name = 'Backstage passes to a TAFKAL80ETC concert' 17 | AND sellIn < 11 18 | AND quality < 50 19 | ; 20 | 21 | UPDATE item 22 | SET 23 | quality = quality + 1 24 | WHERE 1=1 25 | AND NOT ( name <> 'Aged Brie' AND name <> 'Backstage passes to a TAFKAL80ETC concert') 26 | AND quality < 50 27 | AND name = 'Backstage passes to a TAFKAL80ETC concert' 28 | AND sellIn < 6 29 | AND quality < 50 30 | ; 31 | 32 | UPDATE item 33 | SET 34 | sellIn = sellIn - 1 35 | WHERE 1=1 36 | AND name <> 'Sulfuras, Hand of Ragnaros' 37 | ; 38 | 39 | UPDATE item 40 | SET 41 | quality = quality - 1 42 | WHERE 1=1 43 | AND sellIn < 0 44 | AND name <> 'Aged Brie' 45 | AND name <> 'Backstage passes to a TAFKAL80ETC concert' 46 | AND quality > 0 47 | AND name <> 'Sulfuras, Hand of Ragnaros' 48 | ; 49 | 50 | UPDATE item 51 | SET 52 | quality = quality - quality 53 | WHERE 1=1 54 | AND sellIn < 0 55 | AND name <> 'Aged Brie' 56 | AND NOT (name <> 'Backstage passes to a TAFKAL80ETC concert') 57 | ; 58 | 59 | UPDATE item 60 | SET 61 | quality = quality + 1 62 | WHERE 1=1 63 | AND sellIn < 0 64 | AND NOT (name <> 'Aged Brie') 65 | AND quality < 50 66 | AND name <> 'Sulfuras, Hand of Ragnaros' 67 | ; 68 | 69 | COMMIT; -------------------------------------------------------------------------------- /Delphi/TextTestFixture.dpr: -------------------------------------------------------------------------------- 1 | program TextTestFixture; 2 | 3 | {$APPTYPE CONSOLE} 4 | 5 | {$R *.res} 6 | 7 | uses 8 | System.SysUtils, 9 | System.Generics.Collections, 10 | GildedRose in 'GildedRose.pas', 11 | Item in 'Item.pas'; 12 | 13 | var 14 | Days, ErrorCode, I, J: Integer; 15 | Items: TObjectList; 16 | App: TGildedRose; 17 | 18 | begin 19 | try 20 | Writeln('OMGHAI!'); 21 | 22 | Items := TObjectList.Create; 23 | Items.Add(TItem.Create('+5 Dexterity Vest', 10, 20)); 24 | Items.Add(TItem.Create('Aged Brie', 2, 0)); 25 | Items.Add(TItem.Create('Elixir of the Mongoose', 5, 7)); 26 | Items.Add(TItem.Create('Sulfuras, Hand of Ragnaros', 0, 80)); 27 | Items.Add(TItem.Create('Sulfuras, Hand of Ragnaros', -1, 80)); 28 | Items.Add(TItem.Create('Backstage passes to a TAFKAL80ETC concert', 15, 20)); 29 | Items.Add(TItem.Create('Backstage passes to a TAFKAL80ETC concert', 10, 49)); 30 | Items.Add(TItem.Create('Backstage passes to a TAFKAL80ETC concert', 5, 49)); 31 | // this conjured item does not work properly yet 32 | Items.Add(TItem.Create('Conjured Mana Cake', 3, 6)); 33 | 34 | App := TGildedRose.Create(Items); 35 | 36 | Days := 2; 37 | if ParamCount > 0 then 38 | begin 39 | Val(ParamStr(1), Days, ErrorCode); 40 | Inc(Days); 41 | end; 42 | 43 | for I := 0 to Days - 1 do 44 | begin 45 | Writeln(Format('-------- day %d --------', [I])); 46 | Writeln('name, sellIn, quality'); 47 | for J := 0 to Items.Count - 1 do 48 | Writeln(Items[J].ToString); 49 | Writeln; 50 | 51 | App.UpdateQuality; 52 | end; 53 | except 54 | on E: Exception do 55 | Writeln(E.ClassName, ': ', E.Message); 56 | end; 57 | end. 58 | -------------------------------------------------------------------------------- /cpp-catch2/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14..3.16) 2 | set(CMAKE_VERBOSE_MAKEFILE ON) 3 | project(GildedRoseKata VERSION 1.0 4 | DESCRIPTION "The GildedRose Refactoring kata for an approval testing approach" 5 | LANGUAGES CXX) 6 | include(FetchContent) 7 | 8 | FetchContent_Declare( 9 | catch2 10 | GIT_REPOSITORY https://github.com/catchorg/Catch2.git 11 | GIT_TAG v2.12.2 12 | ) 13 | FetchContent_MakeAvailable(catch2) 14 | LIST(APPEND CMAKE_MODULE_PATH 15 | ${catch2_SOURCE_DIR}/contrib 16 | ) 17 | 18 | FetchContent_Declare( 19 | approvaltests_ho 20 | URL https://github.com/approvals/ApprovalTests.cpp/releases/download/v.10.0.0/ApprovalTests.v.10.0.0.hpp 21 | DOWNLOAD_NO_EXTRACT TRUE 22 | DOWNLOAD_DIR ${CMAKE_CURRENT_BINARY_DIR}/approvaltests 23 | DOWNLOAD_NAME ApprovalTests.v.10.0.0.hpp 24 | ) 25 | FetchContent_GetProperties(approvaltests_ho) 26 | if (NOT approvaltests_ho_POPULATED) 27 | FetchContent_Populate(approvaltests_ho) 28 | endif () 29 | add_library(approvaltests INTERFACE) 30 | target_include_directories(approvaltests 31 | INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/approvaltests 32 | INTERFACE ${catch2_SOURCE_DIR}/single_include/catch2 33 | ) 34 | 35 | add_executable(gildedrose_catch2 36 | src/GildedRose.h 37 | src/GildedRose.cc 38 | test/gildedrose_catch.cpp 39 | test/main.cpp) 40 | set_target_properties(gildedrose_catch2 PROPERTIES CXX_STANDARD 11) 41 | target_include_directories(gildedrose_catch2 42 | PUBLIC src) 43 | target_link_libraries(gildedrose_catch2 Catch2::Catch2 approvaltests) 44 | 45 | include(CTest) 46 | include(ParseAndAddCatchTests) 47 | ParseAndAddCatchTests(gildedrose_catch2) -------------------------------------------------------------------------------- /perl6/texttest_fixture.p6: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl6 2 | 3 | use v6; 4 | 5 | use lib 'lib'; 6 | 7 | use GildedRose; 8 | use Item; 9 | 10 | print 'OMGHAI!', "\n"; 11 | my @items = ( 12 | Item.new( 13 | name => '+5 Dexterity Vest', 14 | sell_in => 10, 15 | quality => 20 16 | ), 17 | Item.new( 18 | name => 'Aged Brie', 19 | sell_in => 2, 20 | quality => 0 21 | ), 22 | Item.new( 23 | name => 'Elixir of the Mongoose', 24 | sell_in => 5, 25 | quality => 7 26 | ), 27 | Item.new( 28 | name => 'Sulfuras, Hand of Ragnaros', 29 | sell_in => 0, 30 | quality => 80 31 | ), 32 | Item.new( 33 | name => 'Sulfuras, Hand of Ragnaros', 34 | sell_in => -1, 35 | quality => 80 36 | ), 37 | Item.new( 38 | name => 'Backstage passes to a TAFKAL80ETC concert', 39 | sell_in => 15, 40 | quality => 20 41 | ), 42 | Item.new( 43 | name => 'Backstage passes to a TAFKAL80ETC concert', 44 | sell_in => 10, 45 | quality => 49 46 | ), 47 | Item.new( 48 | name => 'Backstage passes to a TAFKAL80ETC concert', 49 | sell_in => 5, 50 | quality => 49 51 | ), 52 | Item.new( # This Conjured item does not work properly yet 53 | name => 'Conjured Mana Cake', 54 | sell_in => 3, 55 | quality => 6 56 | ), 57 | ); 58 | 59 | sub MAIN(Int $days = 2) { 60 | my $gilded-rose = GildedRose.new( items => @items ); 61 | for ^$days -> $day { 62 | say "-------- day $day --------"; 63 | say 'name, sellIn, quality'; 64 | 65 | .Str.say for $gilded-rose.items; 66 | 67 | "".say; 68 | $gilded-rose.update_quality(); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /R/gilded_rose.R: -------------------------------------------------------------------------------- 1 | source('item.R') 2 | 3 | update_quality <- function(items) { 4 | lapply(items, 5 | function(item) { 6 | 7 | if (item$name != "Aged Brie" && item$name != "Backstage passes to a TAFKAL80ETC concert") { 8 | if (item$quality > 0) { 9 | if (item$name != "Sulfuras, Hand of Ragnaros") { 10 | item$quality <- item$quality - 1 11 | } 12 | } 13 | } else { 14 | if (item$quality < 50) { 15 | item$quality <- item$quality + 1 16 | if (item$name == "Backstage passes to a TAFKAL80ETC concert") { 17 | if (item$sell_in < 11) { 18 | if (item$quality < 50) { 19 | item$quality = item$quality + 1 20 | } 21 | } 22 | if (item$sell_in < 6) { 23 | if (item$quality < 50) { 24 | item$quality = item$quality + 1 25 | } 26 | } 27 | } 28 | } 29 | } 30 | 31 | if (item$name != "Sulfuras, Hand of Ragnaros") { 32 | item$sell_in <- item$sell_in - 1 33 | } 34 | 35 | if (item$sell_in < 0) { 36 | if (item$name != "Aged Brie") { 37 | if (item$name != "Backstage passes to a TAFKAL80ETC concert") { 38 | if (item$quality > 0) { 39 | if (item$name != "Sulfuras, Hand of Ragnaros") { 40 | item$quality <- item$quality - 1 41 | } 42 | } 43 | } else { 44 | item$quality <- item$quality - item$quality 45 | } 46 | } else { 47 | if (item$quality < 50) { 48 | item$quality <- item$quality + 1 49 | } 50 | } 51 | } 52 | 53 | item 54 | } 55 | ) 56 | } 57 | -------------------------------------------------------------------------------- /Delphi/UnitTests.dpr: -------------------------------------------------------------------------------- 1 | program UnitTests; 2 | 3 | {$IFNDEF TESTINSIGHT} 4 | {$APPTYPE CONSOLE} 5 | {$ENDIF}{$STRONGLINKTYPES ON} 6 | uses 7 | System.SysUtils, 8 | {$IFDEF TESTINSIGHT} 9 | TestInsight.DUnitX, 10 | {$ENDIF } 11 | DUnitX.Loggers.Console, 12 | DUnitX.Loggers.Xml.NUnit, 13 | DUnitX.TestFramework, 14 | GildedRoseTests in 'GildedRoseTests.pas'; 15 | 16 | var 17 | runner : ITestRunner; 18 | results : IRunResults; 19 | logger : ITestLogger; 20 | nunitLogger : ITestLogger; 21 | begin 22 | {$IFDEF TESTINSIGHT} 23 | TestInsight.DUnitX.RunRegisteredTests; 24 | exit; 25 | {$ENDIF} 26 | try 27 | //Check command line options, will exit if invalid 28 | TDUnitX.CheckCommandLine; 29 | //Create the test runner 30 | runner := TDUnitX.CreateRunner; 31 | //Tell the runner to use RTTI to find Fixtures 32 | runner.UseRTTI := True; 33 | //tell the runner how we will log things 34 | //Log to the console window 35 | logger := TDUnitXConsoleLogger.Create(true); 36 | runner.AddLogger(logger); 37 | //Generate an NUnit compatible XML File 38 | nunitLogger := TDUnitXXMLNUnitFileLogger.Create(TDUnitX.Options.XMLOutputFile); 39 | runner.AddLogger(nunitLogger); 40 | runner.FailsOnNoAsserts := False; //When true, Assertions must be made during tests; 41 | 42 | //Run tests 43 | results := runner.Execute; 44 | if not results.AllPassed then 45 | System.ExitCode := EXIT_ERRORS; 46 | 47 | {$IFNDEF CI} 48 | //We don't want this happening when running under CI. 49 | if TDUnitX.Options.ExitBehavior = TDUnitXExitBehavior.Pause then 50 | begin 51 | System.Write('Done.. press key to quit.'); 52 | System.Readln; 53 | end; 54 | {$ENDIF} 55 | except 56 | on E: Exception do 57 | System.Writeln(E.ClassName, ': ', E.Message); 58 | end; 59 | end. 60 | -------------------------------------------------------------------------------- /pascal/TEXTTEST.PAS: -------------------------------------------------------------------------------- 1 | program TextTests; 2 | 3 | uses Rose; 4 | 5 | var Items: ListOfItems; 6 | Last: Word; 7 | Days, Day: Integer; 8 | ErrorCode: Integer; 9 | DayStr: string; 10 | I: Word; 11 | begin 12 | WriteLn('OMGHAI!'); 13 | 14 | ResizeList(Items, 9); 15 | 16 | Last := 0; 17 | InitItem(Items.Elements^[Last], '+5 Dexterity Vest', 10, 20); 18 | Inc(Last); 19 | InitItem(Items.Elements^[Last], 'Aged Brie', 2, 0); 20 | Inc(Last); 21 | InitItem(Items.Elements^[Last], 'Elixir of the Mongoose', 5, 7); 22 | Inc(Last); 23 | InitItem(Items.Elements^[Last], 'Sulfuras, Hand of Ragnaros', 0, 80); 24 | Inc(Last); 25 | InitItem(Items.Elements^[Last], 'Sulfuras, Hand of Ragnaros', -1, 80); 26 | Inc(Last); 27 | InitItem(Items.Elements^[Last], 'Backstage passes to a TAFKAL80ETC concert', 15, 20); 28 | Inc(Last); 29 | InitItem(Items.Elements^[Last], 'Backstage passes to a TAFKAL80ETC concert', 10, 49); 30 | Inc(Last); 31 | InitItem(Items.Elements^[Last], 'Backstage passes to a TAFKAL80ETC concert', 5, 49); 32 | Inc(Last); 33 | { this Conjured item doesn't yet work properly } 34 | InitItem(Items.Elements^[Last], 'Conjured Mana Cake', 3, 6); 35 | Inc(Last); 36 | Items.Length := Last; 37 | 38 | Days := 2; 39 | if ParamCount > 0 then 40 | begin 41 | Val(ParamStr(1), Days, ErrorCode); 42 | Inc(Days); 43 | end; 44 | 45 | for Day := 0 to Days-1 do 46 | begin 47 | Str(Day, DayStr); 48 | WriteLn('-------- day ' + DayStr + ' --------'); 49 | WriteLn('name, sellIn, quality'); 50 | for I := 0 to Items.Length-1 do 51 | begin 52 | WriteLn(StrItem(Items.Elements^[I])); 53 | end; 54 | WriteLn(''); 55 | 56 | UpdateQuality(Items); 57 | end; 58 | 59 | ClearList(Items); 60 | end. 61 | -------------------------------------------------------------------------------- /perl/texttest_fixture.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use GildedRose; 7 | use Item; 8 | 9 | print 'OMGHAI!', "\n"; 10 | my $items = [ 11 | Item->new( 12 | name => '+5 Dexterity Vest', 13 | sell_in => 10, 14 | quality => 20 15 | ), 16 | Item->new( 17 | name => 'Aged Brie', 18 | sell_in => 2, 19 | quality => 0 20 | ), 21 | Item->new( 22 | name => 'Elixir of the Mongoose', 23 | sell_in => 5, 24 | quality => 7 25 | ), 26 | Item->new( 27 | name => 'Sulfuras, Hand of Ragnaros', 28 | sell_in => 0, 29 | quality => 80 30 | ), 31 | Item->new( 32 | name => 'Sulfuras, Hand of Ragnaros', 33 | sell_in => -1, 34 | quality => 80 35 | ), 36 | Item->new( 37 | name => 'Backstage passes to a TAFKAL80ETC concert', 38 | sell_in => 15, 39 | quality => 20 40 | ), 41 | Item->new( 42 | name => 'Backstage passes to a TAFKAL80ETC concert', 43 | sell_in => 10, 44 | quality => 49 45 | ), 46 | Item->new( 47 | name => 'Backstage passes to a TAFKAL80ETC concert', 48 | sell_in => 5, 49 | quality => 49 50 | ), 51 | Item->new( # This Conjured item does not work properly yet 52 | name => 'Conjured Mana Cake', 53 | sell_in => 3, 54 | quality => 6 55 | ), 56 | ]; 57 | 58 | my $days = 2; 59 | if ( $#ARGV >= 0 ) { 60 | $days = $ARGV[0]; 61 | } 62 | 63 | my $gilded_rose = GildedRose->new( items => $items ); 64 | for my $day ( 0 .. $days ) { 65 | print "-------- day $day --------", "\n"; 66 | print 'name, sellIn, quality', "\n"; 67 | for my $item ( @{$items} ) { 68 | print $item->to_string(), "\n"; 69 | } 70 | print "\n"; 71 | $gilded_rose->update_quality(); 72 | } 73 | -------------------------------------------------------------------------------- /c99/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for building the kata file with the Google Testing Framework 2 | # 3 | # SYNOPSIS: 4 | # 5 | # make [all] - makes everything, runs tests 6 | # make TARGET - makes the given target. 7 | # make clean - removes all files generated by make. 8 | # make memtest - run memory leak analysis 9 | 10 | # The _POSIX_C_SOURCE definition prevents the compiler from throwing warnings 11 | CFLAGS = `pkg-config --cflags check` -g --std=c99 -D_POSIX_C_SOURCE=200809L 12 | LIBS = `pkg-config --libs check` 13 | 14 | # All files that should be part of your test should start with 'test_' 15 | TEST_SRC = $(wildcard test_*.c) 16 | TEST_BASE = $(basename ${TEST_SRC}) 17 | TEST_OBJECTS = $(addsuffix .o, ${TEST_BASE}) 18 | 19 | # All files that should be part of your main program should start with 'gilded_' 20 | PROG_SRC = $(wildcard gilded_*.c) 21 | PROG_BASE = $(basename ${PROG_SRC}) 22 | PROG_OBJECTS = $(addsuffix .o, ${PROG_BASE}) 23 | 24 | OBJECT_UNDER_TEST = GildedRose.o ${PROG_OBJECTS} 25 | 26 | # This is the test application. You can run this program to see your test output 27 | TEST_APP = test_gildedrose 28 | 29 | 30 | # This will generate output for several products over a course of several days. 31 | # You can run this application to build golden rule tests 32 | GOLDEN_APP = golden_rose 33 | 34 | all: ${TEST_APP} ${GOLDEN_APP} 35 | ./${TEST_APP} 36 | 37 | ${TEST_APP}: ${TEST_OBJECTS} ${OBJECT_UNDER_TEST} 38 | $(CC) $(CFLAGS) -o $@ $^ $(LIBS) 39 | 40 | ${GOLDEN_APP}: GildedRoseTextTests.o ${OBJECT_UNDER_TEST} 41 | $(CC) $(CFLAGS) -o $@ $^ 42 | 43 | # If you're not on a mac, you should run memtest (in fact, consider adding it to the 'all' target). 44 | # If you're on a mac, complain to apple for breaking an important development tool. 45 | memtest: ${TEST_APP} 46 | valgrind --leak-check=full --error-exitcode=1 ./${TEST_APP} --nofork 47 | 48 | clean: 49 | rm -f *.o 50 | rm -f ${TEST_APP} 51 | rm -f ${GOLDEN_APP} 52 | -------------------------------------------------------------------------------- /Delphi/.gitignore: -------------------------------------------------------------------------------- 1 | # Uncomment these types if you want even more clean repository. But be careful. 2 | # It can make harm to an existing project source. Read explanations below. 3 | # 4 | # Resource files are binaries containing manifest, project icon and version info. 5 | # They can not be viewed as text or compared by diff-tools. Consider replacing them with .rc files. 6 | *.res 7 | # 8 | # Type library file (binary). In old Delphi versions it should be stored. 9 | # Since Delphi 2009 it is produced from .ridl file and can safely be ignored. 10 | #*.tlb 11 | # 12 | # Diagram Portfolio file. Used by the diagram editor up to Delphi 7. 13 | # Uncomment this if you are not using diagrams or use newer Delphi version. 14 | #*.ddp 15 | # 16 | # Visual LiveBindings file. Added in Delphi XE2. 17 | # Uncomment this if you are not using LiveBindings Designer. 18 | #*.vlb 19 | # 20 | # Deployment Manager configuration file for your project. Added in Delphi XE2. 21 | # Uncomment this if it is not mobile development and you do not use remote debug feature. 22 | #*.deployproj 23 | # 24 | # C++ object files produced when C/C++ Output file generation is configured. 25 | # Uncomment this if you are not using external objects (zlib library for example). 26 | #*.obj 27 | # 28 | 29 | # Delphi compiler-generated binaries (safe to delete) 30 | *.exe 31 | *.dll 32 | *.bpl 33 | *.bpi 34 | *.dcp 35 | *.so 36 | *.apk 37 | *.drc 38 | *.map 39 | *.dres 40 | *.rsm 41 | *.tds 42 | *.dcu 43 | *.lib 44 | *.a 45 | *.o 46 | *.ocx 47 | 48 | # Delphi autogenerated files (duplicated info) 49 | *.cfg 50 | *.hpp 51 | *Resource.rc 52 | 53 | # Delphi local files (user-specific info) 54 | *.local 55 | *.identcache 56 | *.projdata 57 | *.tvsconfig 58 | *.dsk 59 | 60 | # Delphi history and backups 61 | __history/ 62 | __recovery/ 63 | *.~* 64 | 65 | # Castalia statistics file (since XE7 Castalia is distributed with Delphi) 66 | *.stat 67 | 68 | # Ignore Build outputs 69 | Build 70 | Win32 71 | Win64 72 | -------------------------------------------------------------------------------- /Delphi/GildedRose.groupproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | {3E0B3749-4258-486E-A44B-05088E7E42D6} 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | Default.Personality.12 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /erlang/test/gilded_rose_tests.erl: -------------------------------------------------------------------------------- 1 | -module(gilded_rose_tests). 2 | 3 | -include("gilded_rose.hrl"). 4 | -include_lib("eunit/include/eunit.hrl"). 5 | 6 | -define(ITEMS, [ 7 | #item{name = "+5 Dexterity Vest", sell_in = 10, quality = 20}, 8 | #item{name = "Aged Brie", sell_in = 2, quality = 0}, 9 | #item{name = "Elixir of the Mongoose", sell_in = 5, quality = 7}, 10 | #item{name = "Sulfuras, Hand of Ragnaros", sell_in = 0, quality = 80}, 11 | #item{name = "Sulfuras, Hand of Ragnaros", sell_in = -1, quality = 80}, 12 | #item{name = "Backstage passes to a TAFKAL80ETC concert", sell_in = 15, quality = 20}, 13 | #item{name = "Backstage passes to a TAFKAL80ETC concert", sell_in = 10, quality = 49}, 14 | #item{name = "Backstage passes to a TAFKAL80ETC concert", sell_in = 5, quality = 49}, 15 | #item{name = "Conjured Mana Cake", sell_in = 3, quality = 6} 16 | ]). 17 | 18 | golden_master_test() -> 19 | Days = 30, 20 | {ok, IoDevice} = file:open("actual_output.txt", [write]), 21 | try 22 | lists:foldl(fun(Day, Items) -> 23 | io:format(IoDevice, "-------- day ~p --------~n", [Day]), 24 | io:format(IoDevice, "name, sellIn, quality~n", []), 25 | lists:foreach(fun(#item{name = Name, sell_in = SellIn, quality = Quality}) -> 26 | io:format(IoDevice, "~s, ~p, ~p~n", [Name, SellIn, Quality]) 27 | end, Items), 28 | io:nl(IoDevice), 29 | gilded_rose:update_quality(Items) 30 | end, ?ITEMS, lists:seq(0, Days - 1)) 31 | after 32 | file:close(IoDevice) 33 | end, 34 | case file:read_file("expected_output.txt") of 35 | {ok, ExpectedFile} -> 36 | {ok, ActualFile} = file:read_file("actual_output.txt"), 37 | ?assertEqual(ExpectedFile, ActualFile); 38 | {error, Reason} -> 39 | ?debugFmt("Could not read file 'expected_output.txt': ~p", [Reason]) 40 | end. 41 | 42 | update_quality_test_() -> [ 43 | {"first test", ?_assertMatch([#item{}], gilded_rose:update_quality([#item{}]))} 44 | ]. 45 | -------------------------------------------------------------------------------- /plantuml/history/07_backstage-passes.puml: -------------------------------------------------------------------------------- 1 | @startuml 2 | 3 | skinparam backgroundColor transparent 4 | 5 | start 6 | 7 | if (not "Aged Brie" and not "Backstage passes to a TAFKAL80ETC concert") then (yes) 8 | if (quality > 0) then (yes) 9 | if (not "Sulfuras, Hand of Ragnaros") then (yes) 10 | :lower quality with 1; 11 | else (no) 12 | endif 13 | else (no) 14 | endif 15 | else (no) 16 | if (quality < 50) then (yes) 17 | :increase quality with 1; 18 | if ("Backstage passes to a TAFKAL80ETC concert") then (yes) 19 | if (sell in < 11) then (yes) 20 | if (quality < 50) then (yes) 21 | :increase quality with 1; 22 | else (no) 23 | endif 24 | else (no) 25 | endif 26 | if (sell in < 6) then (yes) 27 | if (quality < 50) then (yes) 28 | :increase quality with 1; 29 | else (no) 30 | endif 31 | else (no) 32 | endif 33 | else (no) 34 | endif 35 | else (no) 36 | endif 37 | endif 38 | 39 | if (not "Sulfuras, Hand of Ragnaros") then (yes) 40 | :lower sell in with 1; 41 | else (no) 42 | endif 43 | 44 | if (sell in < 0) then (yes) 45 | if (not "Aged Brie") then (yes) 46 | if (not "Backstage passes to a TAFKAL80ETC concert") then (yes) 47 | if (quality > 0) then (yes) 48 | if (not "Sulfuras, Hand of Ragnaros") then (yes) 49 | :lower quality with 1; 50 | else (no) 51 | endif 52 | else (no) 53 | endif 54 | else (no) 55 | :lower quality with quality; 56 | endif 57 | else (no) 58 | if (quality < 50) then (yes) 59 | :increase quality with 1; 60 | else (no) 61 | endif 62 | endif 63 | else (no) 64 | endif 65 | 66 | stop 67 | 68 | @enduml 69 | -------------------------------------------------------------------------------- /scala/src/main/scala/com/gildedrose/GildedRose.scala: -------------------------------------------------------------------------------- 1 | package com.gildedrose 2 | 3 | class GildedRose(val items: Array[Item]) { 4 | 5 | 6 | def updateQuality() { 7 | for (i <- 0 until items.length) { 8 | if (!items(i).name.equals("Aged Brie") 9 | && !items(i).name.equals("Backstage passes to a TAFKAL80ETC concert")) { 10 | if (items(i).quality > 0) { 11 | if (!items(i).name.equals("Sulfuras, Hand of Ragnaros")) { 12 | items(i).quality = items(i).quality - 1 13 | } 14 | } 15 | } else { 16 | if (items(i).quality < 50) { 17 | items(i).quality = items(i).quality + 1 18 | 19 | if (items(i).name.equals("Backstage passes to a TAFKAL80ETC concert")) { 20 | if (items(i).sellIn < 11) { 21 | if (items(i).quality < 50) { 22 | items(i).quality = items(i).quality + 1 23 | } 24 | } 25 | 26 | if (items(i).sellIn < 6) { 27 | if (items(i).quality < 50) { 28 | items(i).quality = items(i).quality + 1 29 | } 30 | } 31 | } 32 | } 33 | } 34 | 35 | if (!items(i).name.equals("Sulfuras, Hand of Ragnaros")) { 36 | items(i).sellIn = items(i).sellIn - 1 37 | } 38 | 39 | if (items(i).sellIn < 0) { 40 | if (!items(i).name.equals("Aged Brie")) { 41 | if (!items(i).name.equals("Backstage passes to a TAFKAL80ETC concert")) { 42 | if (items(i).quality > 0) { 43 | if (!items(i).name.equals("Sulfuras, Hand of Ragnaros")) { 44 | items(i).quality = items(i).quality - 1 45 | } 46 | } 47 | } else { 48 | items(i).quality = items(i).quality - items(i).quality 49 | } 50 | } else { 51 | if (items(i).quality < 50) { 52 | items(i).quality = items(i).quality + 1 53 | } 54 | } 55 | } 56 | } 57 | } 58 | } -------------------------------------------------------------------------------- /xslt/xsltunit-0.2/xsltunit_report.xsl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | All Tests 10 | 11 | 12 |

Tests Stylesheet

13 | 14 | 15 | 16 |
17 | 18 | 19 |

Test

20 |
    21 | 22 |
23 |
24 | 25 | 26 |
  • 27 | Assert ... 28 | 29 | 30 | Passed 31 | 32 | 33 | Failed 34 | 35 | 36 | 37 |
  • 38 |
    39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 |
    Expected:
    Actual:
    53 |
    54 | 55 |
    56 | -------------------------------------------------------------------------------- /python/gilded_rose.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | class GildedRose(object): 4 | 5 | def __init__(self, items): 6 | self.items = items 7 | 8 | def update_quality(self): 9 | for item in self.items: 10 | if item.name != "Aged Brie" and item.name != "Backstage passes to a TAFKAL80ETC concert": 11 | if item.quality > 0: 12 | if item.name != "Sulfuras, Hand of Ragnaros": 13 | item.quality = item.quality - 1 14 | else: 15 | if item.quality < 50: 16 | item.quality = item.quality + 1 17 | if item.name == "Backstage passes to a TAFKAL80ETC concert": 18 | if item.sell_in < 11: 19 | if item.quality < 50: 20 | item.quality = item.quality + 1 21 | if item.sell_in < 6: 22 | if item.quality < 50: 23 | item.quality = item.quality + 1 24 | if item.name != "Sulfuras, Hand of Ragnaros": 25 | item.sell_in = item.sell_in - 1 26 | if item.sell_in < 0: 27 | if item.name != "Aged Brie": 28 | if item.name != "Backstage passes to a TAFKAL80ETC concert": 29 | if item.quality > 0: 30 | if item.name != "Sulfuras, Hand of Ragnaros": 31 | item.quality = item.quality - 1 32 | else: 33 | item.quality = item.quality - item.quality 34 | else: 35 | if item.quality < 50: 36 | item.quality = item.quality + 1 37 | 38 | 39 | class Item: 40 | def __init__(self, name, sell_in, quality): 41 | self.name = name 42 | self.sell_in = sell_in 43 | self.quality = quality 44 | 45 | def __repr__(self): 46 | return "%s, %s, %s" % (self.name, self.sell_in, self.quality) 47 | -------------------------------------------------------------------------------- /COBOL/mf/test/TestGildedRose.cbl: -------------------------------------------------------------------------------- 1 | *> Test Fixture for GildedRose, GildedRose 2 | 3 | copy "mfunit_prototypes.cpy". 4 | 5 | program-id. TestGildedRose. 6 | 7 | file-control. 8 | select in-items assign 'in-items'. 9 | select items assign 'items'. 10 | 11 | file section. 12 | fd in-items. 13 | 01 in-item. 14 | 02 sell-in pic 9(4). 15 | 02 quality pic 9(4). 16 | 02 name pic x(50). 17 | fd items. 18 | 01 item. 19 | 02 sell-in pic 9(4). 20 | 02 quality pic 9(4). 21 | 02 name pic x(50). 22 | 23 | working-storage section. 24 | copy "mfunit.cpy". 25 | 78 TEST-TESTGILDEDROSE value "TestGildedRose". 26 | 01 pp procedure-pointer. 27 | 28 | *> Program linkage data 29 | 30 | procedure division. 31 | goback returning 0 32 | . 33 | 34 | entry MFU-TC-PREFIX & TEST-TESTGILDEDROSE. 35 | open output in-items 36 | move "foo" to name in in-item 37 | move 0 to quality in in-item 38 | move 0 to sell-in in in-item 39 | write in-item 40 | close in-items 41 | call "GildedRose" 42 | open input items 43 | read items 44 | if name in item not equal to "fixme" then 45 | call MFU-ASSERT-FAIL-Z using z"item name was not fixme" 46 | close items 47 | goback 48 | . 49 | 50 | $region TestCase Configuration 51 | 52 | entry MFU-TC-SETUP-PREFIX & TEST-TESTGILDEDROSE. 53 | perform InitializeLinkageData 54 | *> Add any other test setup code here 55 | goback returning 0 56 | . 57 | 58 | InitializeLinkageData section. 59 | *> Load the library that is being tested 60 | set pp to entry "GildedRose" 61 | 62 | exit section 63 | . 64 | 65 | $end-region 66 | 67 | end program. 68 | -------------------------------------------------------------------------------- /ruby/gilded_rose.rb: -------------------------------------------------------------------------------- 1 | class GildedRose 2 | 3 | def initialize(items) 4 | @items = items 5 | end 6 | 7 | def update_quality() 8 | @items.each do |item| 9 | if item.name != "Aged Brie" and item.name != "Backstage passes to a TAFKAL80ETC concert" 10 | if item.quality > 0 11 | if item.name != "Sulfuras, Hand of Ragnaros" 12 | item.quality = item.quality - 1 13 | end 14 | end 15 | else 16 | if item.quality < 50 17 | item.quality = item.quality + 1 18 | if item.name == "Backstage passes to a TAFKAL80ETC concert" 19 | if item.sell_in < 11 20 | if item.quality < 50 21 | item.quality = item.quality + 1 22 | end 23 | end 24 | if item.sell_in < 6 25 | if item.quality < 50 26 | item.quality = item.quality + 1 27 | end 28 | end 29 | end 30 | end 31 | end 32 | if item.name != "Sulfuras, Hand of Ragnaros" 33 | item.sell_in = item.sell_in - 1 34 | end 35 | if item.sell_in < 0 36 | if item.name != "Aged Brie" 37 | if item.name != "Backstage passes to a TAFKAL80ETC concert" 38 | if item.quality > 0 39 | if item.name != "Sulfuras, Hand of Ragnaros" 40 | item.quality = item.quality - 1 41 | end 42 | end 43 | else 44 | item.quality = item.quality - item.quality 45 | end 46 | else 47 | if item.quality < 50 48 | item.quality = item.quality + 1 49 | end 50 | end 51 | end 52 | end 53 | end 54 | end 55 | 56 | class Item 57 | attr_accessor :name, :sell_in, :quality 58 | 59 | def initialize(name, sell_in, quality) 60 | @name = name 61 | @sell_in = sell_in 62 | @quality = quality 63 | end 64 | 65 | def to_s() 66 | "#{@name}, #{@sell_in}, #{@quality}" 67 | end 68 | end -------------------------------------------------------------------------------- /plantuml/gilded-rose.puml: -------------------------------------------------------------------------------- 1 | @startuml 2 | 3 | skinparam backgroundColor transparent 4 | 5 | start 6 | note left 7 | Do this for each item in the list. 8 | An item has a name, a sell in value and a quality value 9 | end note 10 | 11 | if (not "Aged Brie" and not "Backstage passes to a TAFKAL80ETC concert") then (yes) 12 | if (quality > 0) then (yes) 13 | if (not "Sulfuras, Hand of Ragnaros") then (yes) 14 | :lower quality with 1; 15 | else (no) 16 | endif 17 | else (no) 18 | endif 19 | else (no) 20 | if (quality < 50) then (yes) 21 | :increase quality with 1; 22 | if ("Backstage passes to a TAFKAL80ETC concert") then (yes) 23 | if (sell in < 11) then (yes) 24 | if (quality < 50) then (yes) 25 | :increase quality with 1; 26 | else (no) 27 | endif 28 | else (no) 29 | endif 30 | if (sell in < 6) then (yes) 31 | if (quality < 50) then (yes) 32 | :increase quality with 1; 33 | else (no) 34 | endif 35 | else (no) 36 | endif 37 | else (no) 38 | endif 39 | else (no) 40 | endif 41 | endif 42 | 43 | if (not "Sulfuras, Hand of Ragnaros") then (yes) 44 | :lower sell in with 1; 45 | else (no) 46 | endif 47 | 48 | if (sell in < 0) then (yes) 49 | if (not "Aged Brie") then (yes) 50 | if (not "Backstage passes to a TAFKAL80ETC concert") then (yes) 51 | if (quality > 0) then (yes) 52 | if (not "Sulfuras, Hand of Ragnaros") then (yes) 53 | :lower quality with 1; 54 | else (no) 55 | endif 56 | else (no) 57 | endif 58 | else (no) 59 | :lower quality with quality; 60 | endif 61 | else (no) 62 | if (quality < 50) then (yes) 63 | :increase quality with 1; 64 | else (no) 65 | endif 66 | endif 67 | else (no) 68 | endif 69 | 70 | stop 71 | 72 | @enduml 73 | -------------------------------------------------------------------------------- /elm/src/GildedRose.elm: -------------------------------------------------------------------------------- 1 | module GildedRose exposing (Item, update_quality) 2 | 3 | 4 | type alias Item = 5 | { name : String 6 | , sell_by : Int 7 | , quality : Int 8 | } 9 | 10 | 11 | update_quality : List Item -> List Item 12 | update_quality items = 13 | List.map 14 | (\item -> 15 | if item.name == "Aged Brie" || item.name == "Backstage passes to a TAFKAL80ETC concert" then 16 | if item.quality < 50 then 17 | if item.name == "Backstage passes to a TAFKAL80ETC concert" then 18 | if item.sell_by < 0 then 19 | { item | sell_by = item.sell_by - 1, quality = 0 } 20 | 21 | else if item.sell_by < 6 then 22 | { item | sell_by = item.sell_by - 1, quality = item.quality + 3 } 23 | 24 | else if item.sell_by < 11 then 25 | { item | sell_by = item.sell_by - 1, quality = item.quality + 2 } 26 | 27 | else 28 | { item | sell_by = item.sell_by - 1, quality = item.quality + 1 } 29 | 30 | else 31 | { item | sell_by = item.sell_by - 1, quality = item.quality + 1 } 32 | 33 | else 34 | { item | sell_by = item.sell_by } 35 | 36 | else if item.name /= "Aged Brie" && item.name /= "Sulfuras, Hand of Ragnaros" then 37 | if item.sell_by < 0 && item.quality > 0 then 38 | if item.quality >= 2 then 39 | { item | sell_by = item.sell_by - 1, quality = item.quality - 2 } 40 | 41 | else 42 | { item | sell_by = item.sell_by - 1, quality = 0 } 43 | 44 | else if item.quality >= 1 then 45 | { item | sell_by = item.sell_by - 1, quality = item.quality - 1 } 46 | 47 | else 48 | { item | sell_by = item.sell_by - 1, quality = 0 } 49 | 50 | else 51 | item 52 | ) 53 | items 54 | -------------------------------------------------------------------------------- /csharp/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace csharp 5 | { 6 | public class Program 7 | { 8 | public static void Main(string[] args) 9 | { 10 | Console.WriteLine("OMGHAI!"); 11 | 12 | IList Items = new List{ 13 | new Item {Name = "+5 Dexterity Vest", SellIn = 10, Quality = 20}, 14 | new Item {Name = "Aged Brie", SellIn = 2, Quality = 0}, 15 | new Item {Name = "Elixir of the Mongoose", SellIn = 5, Quality = 7}, 16 | new Item {Name = "Sulfuras, Hand of Ragnaros", SellIn = 0, Quality = 80}, 17 | new Item {Name = "Sulfuras, Hand of Ragnaros", SellIn = -1, Quality = 80}, 18 | new Item 19 | { 20 | Name = "Backstage passes to a TAFKAL80ETC concert", 21 | SellIn = 15, 22 | Quality = 20 23 | }, 24 | new Item 25 | { 26 | Name = "Backstage passes to a TAFKAL80ETC concert", 27 | SellIn = 10, 28 | Quality = 49 29 | }, 30 | new Item 31 | { 32 | Name = "Backstage passes to a TAFKAL80ETC concert", 33 | SellIn = 5, 34 | Quality = 49 35 | }, 36 | // this conjured item does not work properly yet 37 | new Item {Name = "Conjured Mana Cake", SellIn = 3, Quality = 6} 38 | }; 39 | 40 | var app = new GildedRose(Items); 41 | 42 | 43 | for (var i = 0; i < 31; i++) 44 | { 45 | Console.WriteLine("-------- day " + i + " --------"); 46 | Console.WriteLine("name, sellIn, quality"); 47 | for (var j = 0; j < Items.Count; j++) 48 | { 49 | System.Console.WriteLine(Items[j]); 50 | } 51 | Console.WriteLine(""); 52 | app.UpdateQuality(); 53 | } 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /plsql/update_quality.sql: -------------------------------------------------------------------------------- 1 | CREATE OR REPLACE PROCEDURE update_quality 2 | IS 3 | CURSOR c_items IS 4 | SELECT name, sell_in, quality FROM item FOR UPDATE; 5 | l_item c_items%ROWTYPE; 6 | l_name item.name%TYPE; 7 | l_sell_in item.sell_in%TYPE; 8 | l_quality item.quality%TYPE; 9 | BEGIN 10 | FOR l_item IN c_items 11 | LOOP 12 | l_name := l_item.name; 13 | l_sell_in := l_item.sell_in; 14 | l_quality := l_item.quality; 15 | 16 | IF l_name <> 'Aged Brie' AND l_name <> 'Backstage passes to a TAFKAL80ETC concert' THEN 17 | IF l_quality > 0 THEN 18 | IF l_name <> 'Sulfuras, Hand of Ragnaros' THEN 19 | l_quality := l_quality - 1; 20 | END IF; 21 | END IF; 22 | ELSE 23 | IF (l_quality < 50) THEN 24 | l_quality := l_quality + 1; 25 | IF l_name = 'Backstage passes to a TAFKAL80ETC concert' THEN 26 | IF l_sell_in < 11 THEN 27 | IF l_quality < 50 THEN 28 | l_quality := l_quality + 1; 29 | END IF; 30 | END IF; 31 | IF l_sell_in < 6 THEN 32 | IF l_quality < 50 THEN 33 | l_quality := l_quality + 1; 34 | END IF; 35 | END IF; 36 | END IF; 37 | END IF; 38 | END IF; 39 | 40 | IF l_name <> 'Sulfuras, Hand of Ragnaros' THEN 41 | l_sell_in := l_sell_in - 1; 42 | END IF; 43 | 44 | IF l_sell_in < 0 THEN 45 | IF l_name <> 'Aged Brie' THEN 46 | IF l_name <> 'Backstage passes to a TAFKAL80ETC concert' THEN 47 | IF l_quality > 0 THEN 48 | IF l_name <> 'Sulfuras, Hand of Ragnaros' THEN 49 | l_quality := l_quality - 1; 50 | END IF; 51 | END IF; 52 | ELSE 53 | l_quality := l_quality - l_quality; 54 | END IF; 55 | ELSE 56 | IF l_quality < 50 THEN 57 | l_quality := l_quality + 1; 58 | END IF; 59 | END IF; 60 | END IF; 61 | 62 | UPDATE item 63 | SET name = l_name, sell_in = l_sell_in, quality = l_quality WHERE CURRENT OF c_items; 64 | END LOOP; 65 | END update_quality; 66 | / 67 | -------------------------------------------------------------------------------- /dart/lib/gilded_rose.dart: -------------------------------------------------------------------------------- 1 | class GildedRose { 2 | List items; 3 | 4 | GildedRose(this.items); 5 | 6 | void updateQuality() { 7 | for (int i = 0; i < items.length; i++) { 8 | if (items[i].name != "Aged Brie" && 9 | items[i].name != "Backstage passes to a TAFKAL80ETC concert") { 10 | if (items[i].quality > 0) { 11 | if (items[i].name != "Sulfuras, Hand of Ragnaros") { 12 | items[i].quality = items[i].quality - 1; 13 | } 14 | } 15 | } else { 16 | if (items[i].quality < 50) { 17 | items[i].quality = items[i].quality + 1; 18 | 19 | if (items[i].name == "Backstage passes to a TAFKAL80ETC concert") { 20 | if (items[i].sellIn < 11) { 21 | if (items[i].quality < 50) { 22 | items[i].quality = items[i].quality + 1; 23 | } 24 | } 25 | 26 | if (items[i].sellIn < 6) { 27 | if (items[i].quality < 50) { 28 | items[i].quality = items[i].quality + 1; 29 | } 30 | } 31 | } 32 | } 33 | } 34 | 35 | if (items[i].name != "Sulfuras, Hand of Ragnaros") { 36 | items[i].sellIn = items[i].sellIn - 1; 37 | } 38 | 39 | if (items[i].sellIn < 0) { 40 | if (items[i].name != "Aged Brie") { 41 | if (items[i].name != "Backstage passes to a TAFKAL80ETC concert") { 42 | if (items[i].quality > 0) { 43 | if (items[i].name != "Sulfuras, Hand of Ragnaros") { 44 | items[i].quality = items[i].quality - 1; 45 | } 46 | } 47 | } else { 48 | items[i].quality = items[i].quality - items[i].quality; 49 | } 50 | } else { 51 | if (items[i].quality < 50) { 52 | items[i].quality = items[i].quality + 1; 53 | } 54 | } 55 | } 56 | } 57 | } 58 | } 59 | 60 | class Item { 61 | String name; 62 | int sellIn; 63 | int quality; 64 | 65 | Item(this.name, this.sellIn, this.quality); 66 | 67 | String toString() => '$name, $sellIn, $quality'; 68 | } 69 | -------------------------------------------------------------------------------- /Ada/program.adb: -------------------------------------------------------------------------------- 1 | with Ada.Text_IO; 2 | use Ada.Text_IO; 3 | 4 | with Items; 5 | use Items; 6 | 7 | with Ada.Strings.Unbounded; 8 | use Ada.Strings.Unbounded; 9 | 10 | with Gilded_Rose; 11 | use Gilded_Rose; 12 | 13 | procedure Program is 14 | Things : Item_Vecs.Vector; 15 | begin 16 | Things.Append(New_Item => 17 | (Name => To_Unbounded_String("+5 Dexterity Vest"), 18 | Sell_In => 10, 19 | Quality => 20)); 20 | Things.Append(New_Item => 21 | (Name => To_Unbounded_String("Aged Brie"), 22 | Sell_In => 2, 23 | Quality => 0)); 24 | Things.Append(New_Item => 25 | (Name => To_Unbounded_String("Elixir of the Mongoose"), 26 | Sell_In => 5, 27 | Quality => 7)); 28 | Things.Append(New_Item => 29 | (Name => To_Unbounded_String("Sulfuras, Hand of Ragnaros"), 30 | Sell_In => 0, 31 | Quality => 80)); 32 | Things.Append(New_Item => 33 | (Name => To_Unbounded_String("Sulfuras, Hand of Ragnaros"), 34 | Sell_In => -1, 35 | Quality => 80)); 36 | Things.Append(New_Item => 37 | (Name => To_Unbounded_String("Backstage passes to a TAFKAL80ETC concert"), 38 | Sell_In => 15, 39 | Quality => 20)); 40 | Things.Append(New_Item => 41 | (Name => To_Unbounded_String("Backstage passes to a TAFKAL80ETC concert"), 42 | Sell_In => 10, 43 | Quality => 49)); 44 | Things.Append(New_Item => 45 | (Name => To_Unbounded_String("Backstage passes to a TAFKAL80ETC concert"), 46 | Sell_In => 5, 47 | Quality => 49)); 48 | -- this conjured item does not work properly yet 49 | Things.Append(New_Item => 50 | (Name => To_Unbounded_String("Conjured Mana Cake"), 51 | Sell_In => 3, 52 | Quality => 6)); 53 | 54 | 55 | declare 56 | App : Gilded_Rose.Gilded_Rose := (Items => Things); 57 | begin 58 | Put_Line("OMGHAI!"); 59 | 60 | for I in 0 .. 30 loop 61 | Put_Line("-------- day" & Integer'Image(I) & " --------"); 62 | Put_Line("name, sellIn, quality"); 63 | 64 | for Each of App.Items loop 65 | Put_Line(To_String(Each)); 66 | end loop; 67 | Put_Line(""); 68 | 69 | Update_Quality(App); 70 | end loop; 71 | end; 72 | end; 73 | -------------------------------------------------------------------------------- /csharpcore/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace csharpcore 5 | { 6 | public class Program 7 | { 8 | public static void Main(string[] args) 9 | { 10 | Console.WriteLine("OMGHAI!"); 11 | 12 | IList Items = new List{ 13 | new Item {Name = "+5 Dexterity Vest", SellIn = 10, Quality = 20}, 14 | new Item {Name = "Aged Brie", SellIn = 2, Quality = 0}, 15 | new Item {Name = "Elixir of the Mongoose", SellIn = 5, Quality = 7}, 16 | new Item {Name = "Sulfuras, Hand of Ragnaros", SellIn = 0, Quality = 80}, 17 | new Item {Name = "Sulfuras, Hand of Ragnaros", SellIn = -1, Quality = 80}, 18 | new Item 19 | { 20 | Name = "Backstage passes to a TAFKAL80ETC concert", 21 | SellIn = 15, 22 | Quality = 20 23 | }, 24 | new Item 25 | { 26 | Name = "Backstage passes to a TAFKAL80ETC concert", 27 | SellIn = 10, 28 | Quality = 49 29 | }, 30 | new Item 31 | { 32 | Name = "Backstage passes to a TAFKAL80ETC concert", 33 | SellIn = 5, 34 | Quality = 49 35 | }, 36 | // this conjured item does not work properly yet 37 | new Item {Name = "Conjured Mana Cake", SellIn = 3, Quality = 6} 38 | }; 39 | 40 | var app = new GildedRose(Items); 41 | 42 | 43 | for (var i = 0; i < 31; i++) 44 | { 45 | Console.WriteLine("-------- day " + i + " --------"); 46 | Console.WriteLine("name, sellIn, quality"); 47 | for (var j = 0; j < Items.Count; j++) 48 | { 49 | System.Console.WriteLine(Items[j].Name + ", " + Items[j].SellIn + ", " + Items[j].Quality); 50 | } 51 | Console.WriteLine(""); 52 | app.UpdateQuality(); 53 | } 54 | } 55 | } 56 | } 57 | --------------------------------------------------------------------------------