Skip to content

Commit 6757991

Browse files
authored
Merge pull request #199 from blade-lang/dev
Dev
2 parents 75cdc1f + b5b4789 commit 6757991

25 files changed

+934
-353
lines changed

CMakeLists.txt

Lines changed: 3 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,8 @@ target_link_libraries(blade PRIVATE libblade)
203203

204204
add_custom_target(blade_lib_files ALL
205205
COMMAND ${CMAKE_COMMAND} -E copy_directory "${PROJECT_SOURCE_DIR}/libs" "${OUTPUT_DIR}/libs"
206-
COMMAND ${CMAKE_COMMAND} -E copy_directory "${PROJECT_SOURCE_DIR}/tests" "${OUTPUT_DIR}/tests"
207-
COMMAND ${CMAKE_COMMAND} -E copy_directory "${PROJECT_SOURCE_DIR}/benchmarks" "${OUTPUT_DIR}/benchmarks"
206+
# COMMAND ${CMAKE_COMMAND} -E copy_directory "${PROJECT_SOURCE_DIR}/tests" "${OUTPUT_DIR}/tests"
207+
# COMMAND ${CMAKE_COMMAND} -E copy_directory "${PROJECT_SOURCE_DIR}/benchmarks" "${OUTPUT_DIR}/benchmarks"
208208
COMMAND ${CMAKE_COMMAND} -E copy_directory "${PROJECT_SOURCE_DIR}/apps" "${OUTPUT_DIR}/apps"
209209
COMMAND ${CMAKE_COMMAND} -E copy_directory "${PROJECT_SOURCE_DIR}/bins" "${OUTPUT_DIR}"
210210
COMMENT "Exporting libs, tests, and benchmark scripts..."
@@ -255,90 +255,7 @@ generate_export_header(libblade # generates the export header shared_E
255255
)
256256

257257
enable_testing()
258-
259-
# define a function to simplify adding tests
260-
function(add_blade_test target arg index result)
261-
message(STATUS "setting up test ${arg}_${index} -> tests/${arg}.b")
262-
add_test(NAME ${arg}_${index} COMMAND ${CMAKE_CURRENT_BINARY_DIR}/blade/${PROJECT_NAME} blade/tests/${arg}.b)
263-
set_tests_properties(${arg}_${index}
264-
PROPERTIES PASS_REGULAR_EXPRESSION ${result}
265-
)
266-
endfunction(add_blade_test)
267-
268-
# do a bunch of result based tests
269-
add_blade_test(blade anonymous 0 "works")
270-
add_blade_test(blade anonymous 1 "is the best")
271-
add_blade_test(blade assert 0 "Illegal State:")
272-
add_blade_test(blade assert 1 "empty list expected")
273-
add_blade_test(blade bytes 0 "\\(0 0 0 0 0\\)")
274-
add_blade_test(blade bytes 1 "HELLO")
275-
add_blade_test(blade class 0 "3")
276-
add_blade_test(blade class 1 "10")
277-
add_blade_test(blade class 2 "scone with berries and cream")
278-
add_blade_test(blade class 3 "Person is shouting")
279-
add_blade_test(blade class 4 "2001")
280-
add_blade_test(blade class 5 "Richard. You are 15")
281-
add_blade_test(blade class 6 "Jane. You are 25")
282-
add_blade_test(blade class 7 "A")
283-
add_blade_test(blade class 8 "Name is set")
284-
add_blade_test(blade class 9 "cannot call private method '_echo'")
285-
add_blade_test(blade closure 0 "outer\nreturn from outer\ncreate inner closure\nvalue\n1498500")
286-
add_blade_test(blade condition 0 "Test passed\nTest passed")
287-
add_blade_test(blade dictionary 0 "age: 28")
288-
add_blade_test(blade dictionary 1 "Plot 10,")
289-
add_blade_test(blade dictionary 2 "30")
290-
add_blade_test(blade dictionary 3 "children: 2")
291-
add_blade_test(blade dictionary 4 "{name: Richard, age: 30}")
292-
add_blade_test(blade dictionary 5 "{name: Richard, age: 53}")
293-
add_blade_test(blade dictionary 6 "{name: Alexander, age: 30}")
294-
add_blade_test(blade do 0 "10\n9")
295-
add_blade_test(blade do 1 "2\n1")
296-
add_blade_test(blade die 0 "Exception")
297-
add_blade_test(blade for 0 "address = Nigeria")
298-
add_blade_test(blade for 1 "1 = 7")
299-
add_blade_test(blade for 2 "n\na\nm\ne")
300-
add_blade_test(blade for 3 "12\n13\n14\n15")
301-
add_blade_test(blade for 4 "Richard\nAlex\nJustina")
302-
add_blade_test(blade function 0 "outer")
303-
add_blade_test(blade function 1 "<function test\\(0\\) at 0")
304-
add_blade_test(blade function 2 "It works! inner")
305-
add_blade_test(blade function 3 "Richard")
306-
add_blade_test(blade function 4 "\\[James\\]")
307-
add_blade_test(blade function 5 "Sin 10 = -0.5440211108893656")
308-
add_blade_test(blade if 0 "It works")
309-
add_blade_test(blade if 1 "Nope")
310-
add_blade_test(blade if 2 "2 is less than 5")
311-
add_blade_test(blade if 3 "Ok")
312-
add_blade_test(blade import 0 "Richard,")
313-
add_blade_test(blade import 1 "Alagbaa Estate")
314-
add_blade_test(blade import 2 "It works! inner")
315-
add_blade_test(blade import 3 "Sin 10 =")
316-
add_blade_test(blade import 4 "3.141592653589734")
317-
add_blade_test(blade iter 0 "The new x = 0")
318-
add_blade_test(blade list 0 "\\[\\[1, 2, 4], \\[4, 5, 6\\], \\[7, 8, 9\\]\\]")
319-
add_blade_test(blade logarithm 0 "3.044522437723423\n3.044522437723423")
320-
add_blade_test(blade native 0 "10\n300\n\\[1, 2, 3\\]\n{name: Richard, age: 28}\nA class called A\n")
321-
add_blade_test(blade native 1 "832040\nTime taken")
322-
add_blade_test(blade native 2 "1548008755920\nTime taken")
323-
add_blade_test(blade pi 0 "3.141592653589734")
324-
add_blade_test(blade scope 1 "inner\nouter")
325-
add_blade_test(blade string 0 "25, This is john's LAST 20")
326-
add_blade_test(blade errors 0 "there was an exception")
327-
add_blade_test(blade errors 1 "x is undefined")
328-
add_blade_test(blade errors 2 "<class Exception")
329-
add_blade_test(blade errors 3 "wasn't bound to any variable")
330-
add_blade_test(blade errors 4 "Second exception thrown")
331-
add_blade_test(blade errors 5 "Despite the error, I run because I am in finally")
332-
add_blade_test(blade errors 6 "list index 8 out of range")
333-
add_blade_test(blade errors 7 "Catching exception...")
334-
add_blade_test(blade errors 8 "I am a thrown exception")
335-
add_blade_test(blade errors 9 "Try block called")
336-
add_blade_test(blade errors 10 "Final block called")
337-
add_blade_test(blade errors 11 "Error occurred, but I will still run")
338-
add_blade_test(blade errors 12 "message: I am a thrown exception")
339-
add_blade_test(blade using 0 "ten\nafter")
340-
add_blade_test(blade var 0 "it works\n20\ntrue")
341-
add_blade_test(blade while 0 "x = 51")
258+
add_subdirectory(tests)
342259

343260
# Replace install() with conditional installation.
344261
macro(install)
File renamed without changes.

jetbrains.png

-12.6 KB
Binary file not shown.

src/standard/hash/sha256-slow.h

Lines changed: 0 additions & 184 deletions
This file was deleted.

tests/CMakeLists.txt

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# define a function to simplify adding tests
2+
function(add_blade_test target arg index result)
3+
message(STATUS "setting up test ${arg}_${index} -> tests/${arg}.b")
4+
add_test(NAME ${arg}_${index} COMMAND ${CMAKE_CURRENT_BINARY_DIR}/../blade/${PROJECT_NAME} ../blade/tests/${arg}.b)
5+
set_tests_properties(${arg}_${index}
6+
PROPERTIES PASS_REGULAR_EXPRESSION ${result}
7+
)
8+
endfunction(add_blade_test)
9+
10+
file(GLOB_RECURSE TEST_FILES "${CMAKE_SOURCE_DIR}/tests/*.b")
11+
12+
FOREACH(file_path ${TEST_FILES})
13+
add_test(NAME ${file_path} COMMAND ${CMAKE_CURRENT_BINARY_DIR}/../blade/${PROJECT_NAME} ${file_path})
14+
message(STATUS "Adding test ${file_path}")
15+
ENDFOREACH()
16+
17+
## do a bunch of result based tests
18+
#add_blade_test(blade anonymous 0 "works")
19+
#add_blade_test(blade anonymous 1 "is the best")
20+
#add_blade_test(blade assert 0 "Illegal State:")
21+
#add_blade_test(blade assert 1 "empty list expected")
22+
#add_blade_test(blade bytes 0 "\\(0 0 0 0 0\\)")
23+
#add_blade_test(blade bytes 1 "HELLO")
24+
#add_blade_test(blade class 0 "3")
25+
#add_blade_test(blade class 1 "10")
26+
#add_blade_test(blade class 2 "scone with berries and cream")
27+
#add_blade_test(blade class 3 "Person is shouting")
28+
#add_blade_test(blade class 4 "2001")
29+
#add_blade_test(blade class 5 "Richard. You are 15")
30+
#add_blade_test(blade class 6 "Jane. You are 25")
31+
#add_blade_test(blade class 7 "A")
32+
#add_blade_test(blade class 8 "Name is set")
33+
#add_blade_test(blade class 9 "cannot call private method '_echo'")
34+
#add_blade_test(blade closure 0 "outer\nreturn from outer\ncreate inner closure\nvalue\n1498500")
35+
#add_blade_test(blade condition 0 "Test passed\nTest passed")
36+
#add_blade_test(blade dictionary 0 "age: 28")
37+
#add_blade_test(blade dictionary 1 "Plot 10,")
38+
#add_blade_test(blade dictionary 2 "30")
39+
#add_blade_test(blade dictionary 3 "children: 2")
40+
#add_blade_test(blade dictionary 4 "{name: Richard, age: 30}")
41+
#add_blade_test(blade dictionary 5 "{name: Richard, age: 53}")
42+
#add_blade_test(blade dictionary 6 "{name: Alexander, age: 30}")
43+
#add_blade_test(blade do 0 "10\n9")
44+
#add_blade_test(blade do 1 "2\n1")
45+
#add_blade_test(blade die 0 "Exception")
46+
#add_blade_test(blade for 0 "address = Nigeria")
47+
#add_blade_test(blade for 1 "1 = 7")
48+
#add_blade_test(blade for 2 "n\na\nm\ne")
49+
#add_blade_test(blade for 3 "12\n13\n14\n15")
50+
#add_blade_test(blade for 4 "Richard\nAlex\nJustina")
51+
#add_blade_test(blade function 0 "outer")
52+
#add_blade_test(blade function 1 "<function test\\(0\\) at 0")
53+
#add_blade_test(blade function 2 "It works! inner")
54+
#add_blade_test(blade function 3 "Richard")
55+
#add_blade_test(blade function 4 "\\[James\\]")
56+
#add_blade_test(blade function 5 "Sin 10 = -0.5440211108893656")
57+
#add_blade_test(blade if 0 "It works")
58+
#add_blade_test(blade if 1 "Nope")
59+
#add_blade_test(blade if 2 "2 is less than 5")
60+
#add_blade_test(blade if 3 "Ok")
61+
#add_blade_test(blade import 0 "Richard,")
62+
#add_blade_test(blade import 1 "Alagbaa Estate")
63+
#add_blade_test(blade import 2 "It works! inner")
64+
#add_blade_test(blade import 3 "Sin 10 =")
65+
#add_blade_test(blade import 4 "3.141592653589734")
66+
#add_blade_test(blade iter 0 "The new x = 0")
67+
#add_blade_test(blade list 0 "\\[\\[1, 2, 4], \\[4, 5, 6\\], \\[7, 8, 9\\]\\]")
68+
#add_blade_test(blade logarithm 0 "3.044522437723423\n3.044522437723423")
69+
#add_blade_test(blade native 0 "10\n300\n\\[1, 2, 3\\]\n{name: Richard, age: 28}\nA class called A\n")
70+
#add_blade_test(blade native 1 "832040\nTime taken")
71+
#add_blade_test(blade native 2 "1548008755920\nTime taken")
72+
#add_blade_test(blade pi 0 "3.141592653589734")
73+
#add_blade_test(blade scope 1 "inner\nouter")
74+
#add_blade_test(blade string 0 "25, This is john's LAST 20")
75+
#add_blade_test(blade errors 0 "there was an exception")
76+
#add_blade_test(blade errors 1 "x is undefined")
77+
#add_blade_test(blade errors 2 "<class Exception")
78+
#add_blade_test(blade errors 3 "wasn't bound to any variable")
79+
#add_blade_test(blade errors 4 "Second exception thrown")
80+
#add_blade_test(blade errors 5 "Despite the error, I run because I am in finally")
81+
#add_blade_test(blade errors 6 "list index 8 out of range")
82+
#add_blade_test(blade errors 7 "Catching exception...")
83+
#add_blade_test(blade errors 8 "I am a thrown exception")
84+
#add_blade_test(blade errors 9 "Try block called")
85+
#add_blade_test(blade errors 10 "Final block called")
86+
#add_blade_test(blade errors 11 "Error occurred, but I will still run")
87+
#add_blade_test(blade errors 12 "message: I am a thrown exception")
88+
#add_blade_test(blade using 0 "ten\nafter")
89+
#add_blade_test(blade var 0 "it works\n20\ntrue")
90+
#add_blade_test(blade while 0 "x = 51")

tests/anonymous2.b

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class A {
2+
var x = 1
3+
4+
@to_string() {
5+
return 'Some random string ${self.x}'
6+
}
7+
}
8+
9+
@{
10+
echo to_string(A())
11+
}()

0 commit comments

Comments
 (0)