Skip to content

Commit 62bc291

Browse files
[Patch] Noviq-Rust-Nebula-0.1.2
- Added string interpolation. - Added features file.
1 parent ac8e8c7 commit 62bc291

9 files changed

Lines changed: 1134 additions & 19 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "noviq"
3-
version = "0.1.1"
3+
version = "0.1.2"
44
edition = "2021"
55
authors = ["Noviq Contributors"]
66
description = "A simple, interpreted programming language written in Rust"

README.md

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,10 @@ Noviq aims to be a compiled language instead of an interpreted language in the f
2121
Builder tool for interpreter version is called: Photon or Photon-NVQ
2222
The compiler will be called: Singularity or Singularity-NVQ
2323

24-
First release of Noviq is expected to be Pre-alpha 1.0.0.
24+
First release of Noviq is expected to be Nebula-1.0.0 (Pre-alpha).
2525

2626
## Implementation:
27-
### Pre-aplha (Nebula):
28-
- Basic syntax including but not limited to variables, print, conditionals, etc.
29-
30-
### Aplha (Protostar):
31-
- Including but not limited to everything that includes a basic workstack for a language like loops, functions, libs, a lot more.
32-
- Start building a simple compiler.
33-
34-
### Beta (Nova):
35-
- More advanced features including OOP, etc.
36-
- Compiler should be able to build most of the code.
37-
38-
### Release (Supernova):
39-
- A polished interpreted release of everything implemented before it.
40-
- A fully working compiler which will be polished in future builds.
27+
See features.md
4128

4229
## Building
4330

TESTS.md

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Test Coverage for String Interpolation
2+
3+
## Unit Tests (14 tests in print.rs)
4+
5+
### Basic Interpolation Tests
6+
-`test_interpolate_string_simple` - Single variable interpolation
7+
-`test_interpolate_string_number` - Number interpolation
8+
-`test_interpolate_string_boolean` - Boolean interpolation
9+
-`test_interpolate_string_multiple` - Multiple variables in one string
10+
11+
### Edge Cases
12+
-`test_interpolate_string_no_variables` - String without any variables
13+
-`test_interpolate_string_escaped_braces` - Escaped `{{` braces
14+
-`test_interpolate_string_escaped_closing` - Escaped `}}` braces
15+
16+
### Error Cases
17+
-`test_interpolate_string_undefined_variable` - Undefined variable error
18+
-`test_interpolate_string_empty_variable` - Empty `{}` error
19+
-`test_interpolate_string_unclosed_brace` - Missing closing `}` error
20+
21+
## Integration Tests (6 tests in interpreter/mod.rs)
22+
23+
### End-to-End Tests
24+
-`test_string_interpolation_basic` - Basic interpolation with string variable
25+
-`test_string_interpolation_number` - Interpolation with number variable
26+
-`test_string_interpolation_boolean` - Interpolation with boolean variable
27+
-`test_string_interpolation_multiple` - Multiple variables in statement
28+
-`test_string_interpolation_undefined_variable` - Error handling for undefined vars
29+
-`test_string_without_interpolation` - Plain text without variables
30+
31+
## Test Coverage Summary
32+
33+
**Total Tests**: 27 (increased from 11)
34+
- Frontend (Lexer/Parser): 4 tests
35+
- Runtime (Interpreter): 9 tests
36+
- Builtins (Print): 14 tests
37+
- Utils (Integration): 4 tests
38+
39+
**String Interpolation Coverage**: 20 tests
40+
- Unit tests: 14
41+
- Integration tests: 6
42+
43+
## What's Tested
44+
45+
### Positive Cases
46+
- Single variable interpolation
47+
- Multiple variables in one string
48+
- Different data types (string, number, boolean)
49+
- Text without interpolation
50+
- Escaped braces (`{{` and `}}`)
51+
52+
### Error Cases
53+
- Undefined variables
54+
- Empty variable names `{}`
55+
- Unclosed braces `{name`
56+
- Invalid characters in variable names
57+
58+
### Implementation Details
59+
- Proper error messages
60+
- Correct string concatenation
61+
- Type-to-string conversion
62+
- Variable lookup in scope
63+
64+
## Running the Tests
65+
66+
```bash
67+
# Run all tests
68+
cargo test
69+
70+
# Run only interpolation tests
71+
cargo test interpolate
72+
73+
# Run with output
74+
cargo test -- --nocapture
75+
76+
# Run specific test
77+
cargo test test_interpolate_string_simple
78+
```
79+
80+
## Test Examples
81+
82+
### Basic Interpolation
83+
```rust
84+
let name = "Alice"
85+
print("Hello {name}") // Output: Hello Alice
86+
```
87+
88+
### Multiple Variables
89+
```rust
90+
let name = "Bob"
91+
let age = 30
92+
print("{name} is {age}") // Output: Bob is 30
93+
```
94+
95+
### Error Handling
96+
```rust
97+
print("Hello {undefined}") // Error: Undefined variable: undefined
98+
```
99+
100+
### Escaped Braces
101+
```rust
102+
print("Literal {{braces}}") // Output: Literal {braces}
103+
```

examples/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,16 @@ cargo run -- examples/hello.nvq
1818
- `test.nvq` - Simple test file
1919
- `variables.nvq` - Variable declaration and usage
2020
- `quotes.nvq` - Single and double quote strings
21+
- `showcase.nvq` - Comprehensive feature demonstration
22+
- `interpolation_demo.nvq` - Complete interpolation demo
2123

2224
## Features Demonstrated
2325

2426
- Comments (lines starting with `#`)
2527
- Print statements with `print()`
2628
- String literals (double and single quotes)
29+
- String interpolation with `{variable_name}` syntax
2730
- Variable declarations with `let`
2831
- Numbers (integers and floats)
2932
- Booleans (true/false)
33+
- Escaped braces in strings (`{{` and `}}`)

examples/interpolation_demo.nvq

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Comprehensive string interpolation demo
2+
3+
let name = "Bob"
4+
let age = 30
5+
let height = 5.9
6+
let is_student = false
7+
let score = 87.5
8+
9+
# Basic interpolation
10+
print("Name: {name}")
11+
print("Age: {age} years")
12+
print("Height: {height} feet")
13+
print("Student: {is_student}")
14+
print("Score: {score}%")
15+
16+
# Multiple variables in one string
17+
print("{name} is {age} years old and {height} feet tall")
18+
19+
# Mixed with text
20+
print("User Profile: {name}, Age {age}, Score: {score}%")
21+
22+
# Edge cases
23+
print("No variables here")
24+
print("Escaped braces: {{variable}}")
25+
let test = "value"
26+
print("Mixed: {test} and {{escaped}}")

0 commit comments

Comments
 (0)