Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
test case for rust-mode emacs fix
(defun rust-test-fn (code expected-result)
(with-temp-buffer
(rust-mode)
(insert code)
;; check window before formatting
(let (w-start (window-start))
(message "%s" w-start)
)
(rust-format-buffer)
(should (equal expected-result (buffer-string)))
;; check window start after formatting
(let (w-start (window-start))
(message "%s" w-start)
)
)
)
;; Running the test
(ert-deftest rust-test-formatting-on-save-buffer ()
(rust-test-fn
"struct Foo {}
impl Bar for Foo {
fn dummy_spacer() -> bool {
false
}
fn dummy_spacer() -> bool {
false
}
fn dummy_spacer() -> bool {
false
}
fn dummy_spacer() -> bool {
false
}
fn dummy_spacer() -> bool {
false
}
fn dummy_spacer() -> bool {
false
}
fn dummy_spacer() -> bool {
false
}
fn dummy_spacer() -> bool {
false
}
fn dummy_spacer() -> bool {
false
}
fn dummy_spacer() -> bool {
false
}
fn dummy_spacer() -> bool {
false
}
fn test_function(
&self, param1: String,
param2: String,
param3: String,
param4: String,
) -> bool {
false
}
}
"
"struct Foo {}
impl Bar for Foo {
fn dummy_spacer() -> bool {
false
}
fn dummy_spacer() -> bool {
false
}
fn dummy_spacer() -> bool {
false
}
fn dummy_spacer() -> bool {
false
}
fn dummy_spacer() -> bool {
false
}
fn dummy_spacer() -> bool {
false
}
fn dummy_spacer() -> bool {
false
}
fn dummy_spacer() -> bool {
false
}
fn dummy_spacer() -> bool {
false
}
fn dummy_spacer() -> bool {
false
}
fn dummy_spacer() -> bool {
false
}
fn test_function(
&self,
param1: String,
param2: String,
param3: String,
param4: String,
) -> bool {
false
}
}
"
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.