plum

#treesitter#compiler#wasm

git clone https://git.pyrossh.dev/plum

A statically typed, imperative programming language inspired by rust, python


35bca24Peter John 2026-07-19T17:34:24+05:30
test: add integration tests for format_source
Files changed (1) hide show
  1. plum-core/tests/formatter_test.rs +31 -0
plum-core/tests/formatter_test.rs ADDED
@@ -0,0 +1,31 @@
1
+ use plum_core::format_source;
2
+
3
+ #[test]
4
+ fn formats_simple_function() {
5
+ let input = "main() =\n x = 1\n";
6
+ let result = format_source(input).expect("format_source should succeed");
7
+ assert!(result.contains("main()"));
8
+ assert!(result.contains("x ="));
9
+ }
10
+
11
+ #[test]
12
+ fn formats_binary_operator_spacing() {
13
+ let input = "add<Int>(a: Int, b: Int) -> Int =\n a+b\n";
14
+ let result = format_source(input).expect("format_source should succeed");
15
+ assert!(result.contains("a + b"));
16
+ }
17
+
18
+ #[test]
19
+ fn rejects_syntax_error() {
20
+ let input = "@@@@invalid@@@@\n";
21
+ let result = format_source(input);
22
+ assert!(result.is_err());
23
+ }
24
+
25
+ #[test]
26
+ fn idempotent_on_already_formatted() {
27
+ let input = "main() =\n x = 1 + 2\n";
28
+ let first = format_source(input).expect("first pass");
29
+ let second = format_source(&first).expect("second pass");
30
+ assert_eq!(first, second, "formatting should be idempotent");
31
+ }