1
0

Pass all tests

This commit is contained in:
Jeff 2024-08-23 17:27:11 -04:00
parent e45ac042b9
commit 511cc10e98
3 changed files with 9 additions and 9 deletions

View File

@ -54,11 +54,11 @@ pub fn analyze(source: &str) -> Result<(), DustError> {
/// # use dust_lang::*;
/// let input = "x = 1 + false";
/// let abstract_tree = parse(input).unwrap();
/// let mut context = Context::new();
/// let mut analyzer = Analyzer::new(&abstract_tree, &mut context);
/// let context = Context::new();
/// let mut analyzer = Analyzer::new(&abstract_tree, context);
/// let result = analyzer.analyze();
///
/// assert!(result.is_err());
/// assert!(!analyzer.errors.is_empty());
pub struct Analyzer<'a> {
abstract_tree: &'a AbstractSyntaxTree,
context: Context,

View File

@ -6,8 +6,8 @@
//! use dust_lang::{run, Value};
//!
//! let program = "
//! foo = 21
//! bar = 2
//! let foo = 21
//! let bar = 2
//! foo * bar
//! ";
//!

View File

@ -34,7 +34,7 @@ use crate::{
/// # use dust_lang::value::Value;
/// let result = run("40 + 2");
///
/// assert_eq!(result, Ok(Some(Value::Integer(42))));
/// assert_eq!(result, Ok(Some(Value::integer(42))));
/// ```
pub fn run(source: &str) -> Result<Option<Value>, DustError> {
let context = core_library().create_child();
@ -46,15 +46,15 @@ pub fn run(source: &str) -> Result<Option<Value>, DustError> {
///
/// # Example
/// ```
/// # use dust_lang::{Context, Identifier, Value, run_with_context};
/// # use dust_lang::*;
/// let context = Context::new();
///
/// context.set_value(Identifier::new("foo"), Value::Integer(40));
/// context.set_variable_value(Identifier::new("foo"), Value::integer(40));
/// context.update_last_position(&Identifier::new("foo"), (100, 100));
///
/// let result = run_with_context("foo + 2", context);
///
/// assert_eq!(result, Ok(Some(Value::Integer(42))));
/// assert_eq!(result, Ok(Some(Value::integer(42))));
/// ```
pub fn run_with_context(source: &str, context: Context) -> Result<Option<Value>, DustError> {
let abstract_syntax_tree = parse(source)?;