Skip to content

Commit a944a4e

Browse files
committed
fix: tests mostly working now
1 parent 6d8ef38 commit a944a4e

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

lib/src/tests/arithmetic_methods_class.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,14 @@ fn arithmetic_methods_class() {
7979
"a".to_string(),
8080
TypedExpr(
8181
Box::new(Binary(
82-
"*".to_string(),
83-
Box::new(TypedExpr(
84-
Box::new(LocalOrFieldVar("y".to_string())),
85-
Type::Int,
86-
)),
82+
"/".to_string(),
8783
Box::new(TypedExpr(
8884
Box::new(Binary(
89-
"/".to_string(),
85+
"*".to_string(),
86+
Box::new(TypedExpr(
87+
Box::new(LocalOrFieldVar("y".to_string())),
88+
Type::Int,
89+
)),
9090
Box::new(TypedExpr(
9191
Box::new(Binary(
9292
"+".to_string(),
@@ -105,13 +105,13 @@ fn arithmetic_methods_class() {
105105
)),
106106
Type::Int,
107107
)),
108-
Box::new(TypedExpr(
109-
Box::new(LocalOrFieldVar("x".to_string())),
110-
Type::Int,
111-
)),
112108
)),
113109
Type::Int,
114110
)),
111+
Box::new(TypedExpr(
112+
Box::new(LocalOrFieldVar("x".to_string())),
113+
Type::Int,
114+
)),
115115
)),
116116
Type::Int,
117117
),

lib/src/tests/mod.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,14 @@ fn test_helper(
138138
let class_code = class_to_java(ast);
139139
let mut file = File::create(format!("tests/{name}.java"))
140140
.expect("failed to open original java file for writing generated code");
141+
println!("Generated code: {class_code}");
141142
file.write(class_code.as_bytes())
142143
.map_err(|x| "failed to write generated java code".to_string())?;
143144

144145
// Compile generated java code
145146
let mut child = Command::new("javac")
146147
.arg(format!("tests/{name}.java"))
148+
.arg("-g:none")
147149
.spawn()
148150
.map_err(|x| "failed to compile generated java-code".to_string())?;
149151
let ecode = child
@@ -171,12 +173,13 @@ fn test_helper(
171173
file.write(og_java_code.as_bytes())
172174
.map_err(|x| "failed to write original java code back".to_string())?;
173175
let mut child = Command::new("javac")
174-
.arg(format!("tests/{name}-gen.java"))
176+
.arg(format!("tests/{name}.java"))
177+
.arg("-g:none")
175178
.spawn()
176-
.map_err(|x| "failed to compile generated java-code".to_string())?;
179+
.map_err(|x| "failed to compile original java-code".to_string())?;
177180
let ecode = child
178181
.wait()
179-
.map_err(|x| "failed to wait on child compiling generated java code".to_string())?;
182+
.map_err(|x| "failed to wait on child compiling original java code".to_string())?;
180183
assert!(ecode.success());
181184
let og_clz_file = read(format!("tests/{name}.class"))
182185
.map_err(|x| "failed to read original java class file".to_string())?;

0 commit comments

Comments
 (0)