mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2025-12-12 04:12:13 +00:00
texttext fixture moved into own executable 'main' module.
This commit is contained in:
parent
3db5265f46
commit
99906235bd
1
erlang/.gitignore
vendored
1
erlang/.gitignore
vendored
@ -16,6 +16,5 @@ _build
|
|||||||
*.iml
|
*.iml
|
||||||
rebar3.crashdump
|
rebar3.crashdump
|
||||||
*~
|
*~
|
||||||
*.iml
|
|
||||||
.idea
|
.idea
|
||||||
|
|
||||||
|
|||||||
@ -7,7 +7,12 @@ When you open this project with IntelliJ I recommend that you do
|
|||||||
|
|
||||||
File | New | Project from existing sources
|
File | New | Project from existing sources
|
||||||
|
|
||||||
Then be sure to select "Erlang" as the project type, and configure the rebar3 location correctly.
|
Then be sure to select "Erlang" as the project type, and configure the rebar3 location correctly,
|
||||||
|
(There is a copy of it in this repo).
|
||||||
|
|
||||||
|
If you're having trouble executing the 'main' application, check your module path in your Project Settings.
|
||||||
|
I found I had to manually set the module compile output path to '_build/default/lib/gilded_rose/ebin'.
|
||||||
|
The test output path seemed to be correct as '.eunit'
|
||||||
|
|
||||||
Build
|
Build
|
||||||
-----
|
-----
|
||||||
@ -21,6 +26,6 @@ Run Tests
|
|||||||
|
|
||||||
TextTest Fixture
|
TextTest Fixture
|
||||||
----------------
|
----------------
|
||||||
To run for 30 days:
|
To run for 30 days, I think this ought to work but I tend to run it through the IDE instead:
|
||||||
|
|
||||||
$ update_quality_main.escript 30
|
$ erl -pa _build/default/lib/gilded_rose/ebin -pa . -eval main:main([30]). -s init stop -noshell
|
||||||
|
|||||||
@ -1 +0,0 @@
|
|||||||
-include("GildedRose.hrl").
|
|
||||||
1
erlang/include/texttest_fixture.hrl
Normal file
1
erlang/include/texttest_fixture.hrl
Normal file
@ -0,0 +1 @@
|
|||||||
|
-include("gilded_rose.hrl").
|
||||||
@ -1,2 +1,2 @@
|
|||||||
{erl_opts, [debug_info]}.
|
{erl_opts, [warnings_as_errors]}.
|
||||||
{deps, []}.
|
{eunit_opts, [verbose]}.
|
||||||
@ -1,14 +0,0 @@
|
|||||||
{application, 'GildedRose',
|
|
||||||
[{description, "An OTP library"},
|
|
||||||
{vsn, "0.1.0"},
|
|
||||||
{registered, []},
|
|
||||||
{applications,
|
|
||||||
[kernel,
|
|
||||||
stdlib
|
|
||||||
]},
|
|
||||||
{env,[]},
|
|
||||||
{modules, []},
|
|
||||||
|
|
||||||
{licenses, ["Apache 2.0"]},
|
|
||||||
{links, []}
|
|
||||||
]}.
|
|
||||||
1
erlang/src/gilded_rose.app.src
Normal file
1
erlang/src/gilded_rose.app.src
Normal file
@ -0,0 +1 @@
|
|||||||
|
{application, gilded_rose, [{vsn, "0.1"}]}.
|
||||||
@ -1,6 +1,6 @@
|
|||||||
-module('GildedRose').
|
-module(gilded_rose).
|
||||||
|
|
||||||
-include("GildedRose.hrl").
|
-include("gilded_rose.hrl").
|
||||||
|
|
||||||
-export([
|
-export([
|
||||||
update_quality/1
|
update_quality/1
|
||||||
34
erlang/src/main.erl
Normal file
34
erlang/src/main.erl
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
-module(main).
|
||||||
|
|
||||||
|
-include("texttest_fixture.hrl").
|
||||||
|
|
||||||
|
-export([main/1]).
|
||||||
|
|
||||||
|
-define(ALL_ITEMS, [
|
||||||
|
#item{name = "+5 Dexterity Vest", sell_in = 10, quality = 20},
|
||||||
|
#item{name = "Aged Brie", sell_in = 2, quality = 0},
|
||||||
|
#item{name = "Elixir of the Mongoose", sell_in = 5, quality = 7},
|
||||||
|
#item{name = "Sulfuras, Hand of Ragnaros", sell_in = 0, quality = 80},
|
||||||
|
#item{name = "Sulfuras, Hand of Ragnaros", sell_in = -1, quality = 80},
|
||||||
|
#item{name = "Backstage passes to a TAFKAL80ETC concert", sell_in = 15, quality = 20},
|
||||||
|
#item{name = "Backstage passes to a TAFKAL80ETC concert", sell_in = 10, quality = 49},
|
||||||
|
#item{name = "Backstage passes to a TAFKAL80ETC concert", sell_in = 5, quality = 49},
|
||||||
|
#item{name = "Conjured Mana Cake", sell_in = 3, quality = 6}
|
||||||
|
]).
|
||||||
|
|
||||||
|
main([Days]) ->
|
||||||
|
try
|
||||||
|
texttest_fixture:print_update_quality(Days, ?ALL_ITEMS)
|
||||||
|
catch
|
||||||
|
ExceptionClass:ExceptionInfo ->
|
||||||
|
io:format("something went wrong:~n~p : ~p~n", [ExceptionClass, ExceptionInfo]),
|
||||||
|
usage()
|
||||||
|
end;
|
||||||
|
|
||||||
|
main(_) ->
|
||||||
|
usage().
|
||||||
|
|
||||||
|
usage() ->
|
||||||
|
io:format("usage: main main number_of_days\ne.g. main main [30]\n"),
|
||||||
|
halt(1).
|
||||||
|
|
||||||
@ -1,6 +1,6 @@
|
|||||||
-module('TextTestFixture').
|
-module(texttest_fixture).
|
||||||
|
|
||||||
-include("GildedRose.hrl").
|
-include("texttest_fixture.hrl").
|
||||||
|
|
||||||
-export([print_update_quality/2]).
|
-export([print_update_quality/2]).
|
||||||
|
|
||||||
@ -15,6 +15,7 @@ print_update_quality(Days, Items) ->
|
|||||||
io:format("OMGHAI!"),
|
io:format("OMGHAI!"),
|
||||||
lists:foreach(
|
lists:foreach(
|
||||||
fun(Day) -> print_one_day(Day, Items),
|
fun(Day) -> print_one_day(Day, Items),
|
||||||
'GildedRose':update_quality(Items)
|
gilded_rose:update_quality(Items)
|
||||||
end, lists:seq(0, Days - 1)).
|
end, lists:seq(0, Days - 1)
|
||||||
|
).
|
||||||
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
-module('GildedRoseTest').
|
|
||||||
|
|
||||||
-include_lib("eunit/include/eunit.hrl").
|
|
||||||
|
|
||||||
-include("GildedRose.hrl").
|
|
||||||
|
|
||||||
update_quality_test_() -> [
|
|
||||||
{"foo", ?_assertMatch([#item{name= "FixMe"}], 'GildedRose':update_quality([#item{name = "Foo", sell_in = 0, quality = 0}]))}
|
|
||||||
].
|
|
||||||
9
erlang/test/gilded_rose_test.erl
Normal file
9
erlang/test/gilded_rose_test.erl
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
-module(gilded_rose_test).
|
||||||
|
|
||||||
|
-include_lib("eunit/include/eunit.hrl").
|
||||||
|
|
||||||
|
-include("gilded_rose.hrl").
|
||||||
|
|
||||||
|
update_quality_test_() -> [
|
||||||
|
{"foo", ?_assertMatch([#item{name= "Foo"}], gilded_rose:update_quality([#item{name = "Foo", sell_in = 0, quality = 0}]))}
|
||||||
|
].
|
||||||
Loading…
Reference in New Issue
Block a user