Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation audience member and transcript #1

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,18 @@ git clone https://github.com/MichaelDimmitt/transcript-fromElixirWorkshop.git;
cd transcript-fromElixirWorkshop;
iex -S mix;
```
#Usage Below

## bash
`iex -S mix`

## iex syntax:
```elixir
stack = Conversation.new
Conversation.pop(stack)
Conversation.pop(stack)
Conversation.pop(stack)
Conversation.pop(stack)
Conversation.pop(stack)
```

23 changes: 15 additions & 8 deletions lib/conversation.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,23 @@ defmodule Conversation do
Documentation for Conversation.
"""

@doc """
Hello world.
def new do
stack = Conversation.audience_member
Conversation.transcript(stack)
Conversation.transcript(stack)
stack
end

## Examples
def audience_member do
Stack.new
end

iex> Conversation.hello
:world
def transcript (stack) do
Stack.push(stack, :foo)
Stack.push(stack, :bar)
end

"""
def hello do
:world
def pop(stack) do
Stack.pop(stack)
end
end
2 changes: 2 additions & 0 deletions lib/stack.ex
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ defmodule Stack do

receive do
{:pop, val} -> val
after
1000 -> :ok
end

end
Expand Down
42 changes: 40 additions & 2 deletions test/conversation_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,45 @@ defmodule ConversationTest do
use ExUnit.Case
doctest Conversation

test "greets the world" do
assert Conversation.hello() == :world
test "first bar" do
stack = Conversation.new
|> IO.inspect
assert [Conversation.pop(stack)] == [:bar]
Conversation.pop(stack)
end

test "second foo" do
stack = Conversation.new
Conversation.pop(stack)
assert [Conversation.pop(stack)] == [:foo]
IO.puts('end')
end

test "third, bar" do
stack = Conversation.new
Conversation.pop(stack)
Conversation.pop(stack)
assert [Conversation.pop(stack)] == [:bar]
IO.puts('end')
end

test "fourth, error" do
stack = Conversation.new
Conversation.pop(stack)
Conversation.pop(stack)
Conversation.pop(stack)
assert [Conversation.pop(stack)] == [:foo]
IO.puts('end')
end

test "fifth, error" do
stack = Conversation.new
Conversation.pop(stack)
Conversation.pop(stack)
Conversation.pop(stack)
Conversation.pop(stack)
assert [Conversation.pop(stack)] == [:ok]
IO.puts('end')
end

end