Skip to content

Commit b6ce1d6

Browse files
committed
add tests
1 parent 04024fb commit b6ce1d6

23 files changed

+367
-0
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
4444
set(CMAKE_CXX_STANDARD 17)
4545
set(CMAKE_CXX_STANDARD_REQUIRED ON)
4646

47+
enable_testing()
48+
4749
add_subdirectory(src)
4850

4951
feature_summary(

Gemfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# frozen_string_literal: true
2+
3+
source "https://rubygems.org"
4+
5+
# gem "rails"
6+
7+
gem "minitest", "~> 5.15"

Gemfile.lock

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
minitest (5.15.0)
5+
6+
PLATFORMS
7+
arm64-darwin-21
8+
9+
DEPENDENCIES
10+
minitest (~> 5.15)
11+
12+
BUNDLED WITH
13+
2.3.7

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ cmake --preset dev
4040
# compile it
4141
cmake --build --preset dev
4242

43+
# test it
44+
ruby ./test/rq_test.rb
45+
4346
# run it
4447
./build/src/rq
4548
```

src/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ add_executable(rq
1010
${PROJECT_SOURCES}
1111
)
1212

13+
add_test(
14+
NAME rq_test
15+
COMMAND ruby ${CMAKE_SOURCE_DIR}/test/rq_test.rb
16+
)
17+
set_property(
18+
TEST rq_test
19+
PROPERTY ENVIRONMENT RQ_BIN=$<TARGET_FILE:rq>
20+
)
21+
1322
target_link_libraries(rq PRIVATE
1423
${MRUBY_LIBS}
1524
)

test/fixtures/basic_array.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[
2+
{ "id": 1, "foo": true, "bar": { "name": "Bugs", "price_min": 0.5, "price_max": 30.0 } },
3+
{ "id": 2, "foo": false, "bar": { "name": "Features", "price_min": 1.2, "price_max": 29.95 } },
4+
{ "id": 3, "foo": true, "bar": { "name": "Ruby", "price_min": 3.5, "price_max": 21.44 } },
5+
{ "id": 4, "foo": true, "bar": { "name": "FooBar", "price_min": 0.3, "price_max": 45.32 } },
6+
{ "id": 5, "foo": false, "bar": { "name": "High5", "price_min": 13.37, "price_max": 420.69 } }
7+
]

test/fixtures/basic_object.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "Jyrki",
3+
"location": "Europe",
4+
"languages": [
5+
"C++",
6+
"Crystal",
7+
"Ruby",
8+
"Turbo Pascal"
9+
]
10+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
rq: expression .unknown_method failed to run:
2+
(unknown):0: undefined method 'unknown_method' (NoMethodError)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
reading from stdin
2+
running 1 expressions
3+
----> item = (item.unknown_method)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
reading from stdin
2+
running 2 expressions
3+
----> item = (item["languages"])
4+
----> item = (item.select { |lang| %w[C++ Ruby].include?(lang) })
5+
printing item
6+
[
7+
"C++",
8+
"Ruby"
9+
]

0 commit comments

Comments
 (0)