Page MenuHomePhorge

No OneTemporary

Size
3 KB
Referenced Files
None
Subscribers
None
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
index 0000000..a57443d
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,37 @@
+image: elixir:1.7
+
+variables:
+ MIX_ENV: test
+
+cache:
+ key: ${CI_COMMIT_REF_SLUG}
+ paths:
+ - deps
+ - _build
+
+stages:
+ - test
+ - publish
+
+before_script:
+ - mix local.hex --force
+ - mix local.rebar --force
+ - mix deps.get
+ - mix compile --force
+
+lint:
+ stage: test
+ script:
+ - mix format --check-formatted
+
+unit-testing:
+ stage: test
+ coverage: '/(\d+\.\d+\%) \| Total/'
+ script:
+ - mix test --trace --preload-modules --cover
+
+analysis:
+ stage: test
+ script:
+ - mix credo --strict --only=warnings,todo,fixme,consistency,readability
+
diff --git a/mix.exs b/mix.exs
index 0bfc85e..41afeca 100644
--- a/mix.exs
+++ b/mix.exs
@@ -1,35 +1,38 @@
defmodule BBCode.MixProject do
use Mix.Project
def project do
[
app: :bbcode,
name: "BBCode",
description: "BBCode parsing for Elixir",
version: "0.1.0",
elixir: "~> 1.7",
start_permanent: Mix.env() == :prod,
deps: deps(),
package: package()
]
end
def application do
[
extra_applications: [:logger]
]
end
defp deps do
[
- {:nimble_parsec, "~> 0.2"}
+ {:nimble_parsec, "~> 0.2"},
+ {:credo, "~> 1.0.0", only: [:dev, :test], runtime: false},
+ {:ex_doc, "~> 0.19", only: :dev, runtime: false},
+ {:dialyxir, "~> 1.0.0-rc.5", only: [:dev], runtime: false}
]
end
defp package do
[
licenses: ["LGPLv3"],
links: %{"GitLab" => "https://git.pleroma.social/pleroma/bbcode"}
]
end
end
diff --git a/test/bbcode/parser_test.exs b/test/bbcode/parser_test.exs
new file mode 100644
index 0000000..a798dbf
--- /dev/null
+++ b/test/bbcode/parser_test.exs
@@ -0,0 +1,46 @@
+defmodule BBCode.Parser.Test do
+ use ExUnit.Case
+ alias BBCode.Parser
+
+ describe "simple tags" do
+ test "it parses [b] tags correctly" do
+ assert {:ok, [b: "testing"]} = Parser.parse("[b]testing[/b]")
+ end
+
+ test "it parses [i] tags correctly" do
+ assert {:ok, [i: "testing"]} = Parser.parse("[i]testing[/i]")
+ end
+
+ test "it parses [u] tags correctly" do
+ assert {:ok, [u: "testing"]} = Parser.parse("[u]testing[/u]")
+ end
+
+ test "it parses [s] tags correctly" do
+ assert {:ok, [s: "testing"]} = Parser.parse("[s]testing[/s]")
+ end
+
+ test "it parses [code] tags correctly" do
+ assert {:ok, [code: "testing"]} = Parser.parse("[code]testing[/code]")
+ end
+
+ test "it parses [quote] tags correctly" do
+ assert {:ok, [quote: "testing"]} = Parser.parse("[quote]testing[/quote]")
+ end
+ end
+
+ describe "nested tags" do
+ test "it parses [ul] lists correctly" do
+ assert {:ok, [ul: [li: "a", li: "b"]]} = Parser.parse("[ul][li]a[/li][li]b[/li][/ul]")
+ end
+
+ test "it parses [ol] lists correctly" do
+ assert {:ok, [ol: [li: "a", li: "b"]]} = Parser.parse("[ol][li]a[/li][li]b[/li][/ol]")
+ end
+ end
+
+ describe "invalid input" do
+ test "it fails to parse unterminated input" do
+ {:error, "expected end of string"} = Parser.parse("hello [b]world")
+ end
+ end
+end
diff --git a/test/bbcode_test.exs b/test/bbcode_test.exs
deleted file mode 100644
index 2c92bf6..0000000
--- a/test/bbcode_test.exs
+++ /dev/null
@@ -1,8 +0,0 @@
-defmodule BbcodeTest do
- use ExUnit.Case
- doctest Bbcode
-
- test "greets the world" do
- assert Bbcode.hello() == :world
- end
-end

File Metadata

Mime Type
text/x-diff
Expires
Wed, Nov 27, 12:43 PM (1 d, 15 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
40640
Default Alt Text
(3 KB)

Event Timeline