Skip to content

Commit

Permalink
Update bench to new formatter api
Browse files Browse the repository at this point in the history
  • Loading branch information
Erin van der Veen committed Jan 3, 2024
1 parent 7d55809 commit 0a0613b
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions topiary/benches/benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,29 @@ use criterion::async_executor::FuturesExecutor;
use criterion::{criterion_group, criterion_main, Criterion};
use std::fs;
use std::io;
use topiary::{formatter, Operation};
use topiary::{Configuration, TopiaryQuery};
use topiary::{formatter, Language, Operation, TopiaryQuery};

// FIXME Configuration is no longer part of the library

async fn format() {
let input = fs::read_to_string("tests/samples/input/ocaml.ml").unwrap();
let query_content = fs::read_to_string("../queries/ocaml.scm").unwrap();
let configuration = Configuration::parse_default_configuration().unwrap();
let language = configuration.get_language("ocaml").unwrap();
let grammar = language.grammar().await.unwrap();
let query = TopiaryQuery::new(&grammar, &query_content).unwrap();
let ocaml = tree_sitter_ocaml::language_ocaml();

let mut input = input.as_bytes();
let mut output = io::BufWriter::new(Vec::new());

let language: Language = Language {
name: "ocaml".to_owned(),
query: TopiaryQuery::new(&ocaml.into(), &query_content).unwrap(),
grammar: ocaml.into(),
indent: None,
};

formatter(
&mut input,
&mut output,
&query,
language,
&grammar,
&language,
Operation::Format {
skip_idempotence: true,
tolerate_parsing_errors: false,
Expand Down

0 comments on commit 0a0613b

Please sign in to comment.