dol 0.8.1

DOL (Design Ontology Language) - A declarative specification language for ontology-first development
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
//! Module System Edge Case Tests for DOL
//!
//! Tests module system edge cases:
//! - Circular dependency detection
//! - Diamond dependency patterns
//! - Name shadowing across modules
//! - Re-export chains
//! - Version conflict resolution
//! - Missing dependency handling
//! - Visibility boundary violations
//!
//! These tests help discover bugs in the module resolver and import system.

use metadol::ast::{ImportSource, UseItems, Visibility};
use metadol::parser::Parser;
use metadol::{parse_dol_file, parse_file, parse_file_all};

// ============================================================================
// CIRCULAR DEPENDENCY TESTS
// ============================================================================

mod circular_deps {
    use super::*;

    #[test]
    fn direct_circular_reference() {
        // Module A uses Module B, Module B uses Module A
        let module_a = r#"
module a @ 1.0.0

use b.Thing

gen AThing {
    has b_ref: Thing
}
"#;

        let module_b = r#"
module b @ 1.0.0

use a.AThing

gen Thing {
    has a_ref: AThing
}
"#;

        // Both should parse independently
        let result_a = parse_dol_file(module_a);
        let result_b = parse_dol_file(module_b);

        assert!(
            result_a.is_ok(),
            "Module A should parse: {:?}",
            result_a.err()
        );
        assert!(
            result_b.is_ok(),
            "Module B should parse: {:?}",
            result_b.err()
        );

        // NOTE: Actual circular dependency detection happens at link time
        println!("NOTE: Circular deps should be detected at link/compile time, not parse time");
    }

    #[test]
    fn transitive_circular_reference() {
        // A -> B -> C -> A
        let module_a = r#"
module a @ 1.0.0

use b.BThing

gen AThing {
    has b: BThing
}
"#;

        let module_b = r#"
module b @ 1.0.0

use c.CThing

gen BThing {
    has c: CThing
}
"#;

        let module_c = r#"
module c @ 1.0.0

use a.AThing

gen CThing {
    has a: AThing
}
"#;

        // All should parse
        assert!(parse_dol_file(module_a).is_ok());
        assert!(parse_dol_file(module_b).is_ok());
        assert!(parse_dol_file(module_c).is_ok());

        println!("NOTE: Transitive circular deps (A->B->C->A) should be detected at link time");
    }

    #[test]
    fn self_referential_module() {
        // Module that tries to use itself
        let source = r#"
module self_ref @ 1.0.0

use self_ref.Thing

gen Thing {
    has value: i64
}
"#;

        let result = parse_dol_file(source);

        // Parser might accept this; semantic analysis should catch it
        match result {
            Ok(_) => println!("NOTE: Self-referential use parses (caught at semantic level?)"),
            Err(e) => println!("NOTE: Self-referential use rejected at parse: {:?}", e),
        }
    }

    #[test]
    fn circular_via_wildcard_import() {
        // Circular dependency via glob import
        let module_a = r#"
module a @ 1.0.0

use b.*

gen AThing {
    has data: i64
}
"#;

        let module_b = r#"
module b @ 1.0.0

use a.*

gen BThing {
    has data: i64
}
"#;

        assert!(parse_dol_file(module_a).is_ok());
        assert!(parse_dol_file(module_b).is_ok());

        println!("NOTE: Glob import circularity should be detected at resolve time");
    }
}

// ============================================================================
// DIAMOND DEPENDENCY TESTS
// ============================================================================

mod diamond_deps {
    use super::*;

    #[test]
    fn basic_diamond_pattern() {
        // Classic diamond: A depends on B and C, both B and C depend on D
        let module_d = r#"
module d @ 1.0.0

gen Shared {
    has value: i64
}
"#;

        let module_b = r#"
module b @ 1.0.0

use d.Shared

gen BType {
    has shared: Shared
}
"#;

        let module_c = r#"
module c @ 1.0.0

use d.Shared

gen CType {
    has shared: Shared
}
"#;

        let module_a = r#"
module a @ 1.0.0

use b.BType
use c.CType
use d.Shared

gen AType {
    has b: BType
    has c: CType
    has direct: Shared
}
"#;

        // All should parse
        assert!(parse_dol_file(module_d).is_ok());
        assert!(parse_dol_file(module_b).is_ok());
        assert!(parse_dol_file(module_c).is_ok());
        assert!(parse_dol_file(module_a).is_ok());

        println!("NOTE: Diamond pattern (A->B->D, A->C->D) should work with single instance of D");
    }

    #[test]
    fn diamond_with_version_conflict() {
        // Diamond where B uses D@1.0 and C uses D@2.0
        let module_b = r#"
module b @ 1.0.0

use @univrs/d @ 1.0.0

gen BType {
    has data: i64
}
"#;

        let module_c = r#"
module c @ 1.0.0

use @univrs/d @ 2.0.0

gen CType {
    has data: i64
}
"#;

        let module_a = r#"
module a @ 1.0.0

use b.BType
use c.CType

gen AType {
    has b: BType
    has c: CType
}
"#;

        // Should parse - version resolution happens at link time
        assert!(parse_dol_file(module_b).is_ok());
        assert!(parse_dol_file(module_c).is_ok());
        assert!(parse_dol_file(module_a).is_ok());

        println!("NOTE: Diamond with version conflict should be resolved by package manager");
    }

    #[test]
    fn diamond_with_re_export() {
        // Diamond where B re-exports from D, C imports from B
        let module_d = r#"
module d @ 1.0.0

pub gen Shared {
    has value: i64
}
"#;

        let module_b = r#"
module b @ 1.0.0

pub use d.Shared

gen BType {
    has shared: Shared
}
"#;

        let module_c = r#"
module c @ 1.0.0

use b.Shared

gen CType {
    has shared: Shared
}
"#;

        assert!(parse_dol_file(module_d).is_ok());
        assert!(parse_dol_file(module_b).is_ok());
        assert!(parse_dol_file(module_c).is_ok());

        println!("NOTE: Re-export chains should resolve to same type");
    }
}

// ============================================================================
// NAME SHADOWING TESTS
// ============================================================================

mod shadowing {
    use super::*;

    #[test]
    fn local_shadows_import() {
        let source = r#"
module test @ 1.0.0

use other.Thing

gen Thing {
    has value: i64
}

gen User {
    has t: Thing
}
"#;

        let result = parse_dol_file(source);
        assert!(result.is_ok(), "Local shadowing import should parse");

        println!("NOTE: Local 'Thing' should shadow imported 'Thing' - verify at semantic level");
    }

    #[test]
    fn import_shadows_builtin() {
        let source = r#"
module test @ 1.0.0

use custom.i64

gen Test {
    has value: i64
}
"#;

        let result = parse_dol_file(source);

        match result {
            Ok(_) => println!("NOTE: Shadowing builtin 'i64' is allowed (verify semantics)"),
            Err(e) => println!("NOTE: Shadowing builtin 'i64' is forbidden: {:?}", e),
        }
    }

    #[test]
    fn qualified_vs_unqualified() {
        let source = r#"
module test @ 1.0.0

use a.Thing
use b.Thing as OtherThing

gen Local {
    has a: Thing
    has b: OtherThing
    has c: a.Thing
    has d: b.Thing
}
"#;

        let result = parse_dol_file(source);
        assert!(
            result.is_ok(),
            "Qualified and unqualified names should parse: {:?}",
            result.err()
        );
    }

    #[test]
    fn nested_module_shadowing() {
        let source = r#"
module parent.child @ 1.0.0

use parent.Thing

gen Thing {
    has local: i64
}

gen Test {
    has child_thing: Thing
    has parent_thing: parent.Thing
}
"#;

        let result = parse_dol_file(source);
        match result {
            Ok(_) => println!("NOTE: Child module can shadow parent's types"),
            Err(e) => println!("NOTE: Child shadowing parent rejected: {:?}", e),
        }
    }

    #[test]
    fn multiple_glob_imports_conflict() {
        let source = r#"
module test @ 1.0.0

use a.*
use b.*

gen User {
    has t: Thing
}
"#;

        let result = parse_dol_file(source);

        // Parser accepts this; ambiguity would be caught at name resolution
        match result {
            Ok(_) => println!("NOTE: Multiple glob imports parse - ambiguity checked later"),
            Err(e) => println!("NOTE: Multiple glob imports rejected: {:?}", e),
        }
    }

    #[test]
    fn alias_same_as_existing() {
        let source = r#"
module test @ 1.0.0

gen Thing { has value: i64 }

use other.Different as Thing
"#;

        let result = parse_dol_file(source);

        match result {
            Ok(_) => println!("NOTE: Aliasing to existing name allowed at parse time"),
            Err(e) => println!("NOTE: Aliasing to existing name rejected: {:?}", e),
        }
    }
}

// ============================================================================
// RE-EXPORT CHAIN TESTS
// ============================================================================

mod re_exports {
    use super::*;

    #[test]
    fn simple_re_export() {
        let source = r#"
module reexport @ 1.0.0

pub use original.Thing
pub use original.{A, B, C}
"#;

        let result = parse_dol_file(source);
        assert!(result.is_ok(), "Simple re-export should parse");

        if let Ok(file) = result {
            assert_eq!(file.uses.len(), 2);
            assert!(matches!(file.uses[0].visibility, Visibility::Public));
        }
    }

    #[test]
    fn re_export_with_rename() {
        let source = r#"
module facade @ 1.0.0

pub use internal.InternalThing as PublicThing
pub use internal.{A as Alpha, B as Beta}
"#;

        let result = parse_dol_file(source);
        assert!(result.is_ok(), "Re-export with rename should parse");
    }

    #[test]
    fn chained_re_exports() {
        // A re-exports from B, B re-exports from C
        let module_c = r#"
module c @ 1.0.0

pub gen Original {
    has value: i64
}
"#;

        let module_b = r#"
module b @ 1.0.0

pub use c.Original
"#;

        let module_a = r#"
module a @ 1.0.0

pub use b.Original
"#;

        assert!(parse_dol_file(module_c).is_ok());
        assert!(parse_dol_file(module_b).is_ok());
        assert!(parse_dol_file(module_a).is_ok());

        println!("NOTE: Chained re-exports (A->B->C) should resolve to same type");
    }

    #[test]
    fn re_export_glob() {
        let source = r#"
module reexport @ 1.0.0

pub use internal.*
"#;

        let result = parse_dol_file(source);

        match result {
            Ok(file) => {
                assert!(matches!(file.uses[0].visibility, Visibility::Public));
                println!("NOTE: Glob re-export is supported");
            }
            Err(e) => println!("NOTE: Glob re-export rejected: {:?}", e),
        }
    }

    #[test]
    fn private_type_re_exported() {
        // Module that tries to re-export a private type
        let module_internal = r#"
module internal @ 1.0.0

gen PrivateThing {
    has secret: i64
}
"#;

        let module_facade = r#"
module facade @ 1.0.0

pub use internal.PrivateThing
"#;

        // Both parse - visibility check is semantic
        assert!(parse_dol_file(module_internal).is_ok());
        assert!(parse_dol_file(module_facade).is_ok());

        println!("NOTE: Re-exporting private types should fail at semantic check");
    }
}

// ============================================================================
// VERSION CONSTRAINT TESTS
// ============================================================================

mod version_constraints {
    use super::*;

    #[test]
    fn exact_version_requirement() {
        let source = r#"
module test @ 1.0.0

use @univrs/core = 2.3.4
"#;

        let result = parse_dol_file(source);
        assert!(
            result.is_ok(),
            "Exact version requirement should parse: {:?}",
            result.err()
        );
    }

    #[test]
    fn minimum_version_requirement() {
        let source = r#"
module test @ 1.0.0

use @univrs/core >= 1.0.0
"#;

        let result = parse_dol_file(source);

        match result {
            Ok(_) => println!("NOTE: >= version constraint is supported"),
            Err(e) => println!("NOTE: >= version constraint not supported: {:?}", e),
        }
    }

    #[test]
    fn caret_version() {
        let source = r#"
module test @ 1.0.0

use @univrs/core @ ^1.2.3
"#;

        let result = parse_dol_file(source);

        match result {
            Ok(_) => println!("NOTE: Caret version (^1.2.3) is supported"),
            Err(e) => println!("NOTE: Caret version not supported: {:?}", e),
        }
    }

    #[test]
    fn tilde_version() {
        let source = r#"
module test @ 1.0.0

use @univrs/core @ ~1.2.3
"#;

        let result = parse_dol_file(source);

        match result {
            Ok(_) => println!("NOTE: Tilde version (~1.2.3) is supported"),
            Err(e) => println!("NOTE: Tilde version not supported: {:?}", e),
        }
    }

    #[test]
    fn version_range() {
        let source = r#"
module test @ 1.0.0

use @univrs/core >= 1.0.0 < 2.0.0
"#;

        let result = parse_dol_file(source);

        match result {
            Ok(_) => println!("NOTE: Version range is supported"),
            Err(e) => println!("NOTE: Version range not supported: {:?}", e),
        }
    }

    #[test]
    fn prerelease_version() {
        let source = r#"
module test @ 1.0.0-alpha.1

use @univrs/core @ 2.0.0-beta.5
"#;

        let result = parse_dol_file(source);

        match result {
            Ok(_) => println!("NOTE: Prerelease versions are supported"),
            Err(e) => println!("NOTE: Prerelease versions not supported: {:?}", e),
        }
    }
}

// ============================================================================
// MISSING DEPENDENCY TESTS
// ============================================================================

mod missing_deps {
    use super::*;

    #[test]
    fn use_nonexistent_module() {
        let source = r#"
module test @ 1.0.0

use nonexistent.module.Thing

gen User {
    has t: Thing
}
"#;

        let result = parse_dol_file(source);

        // Parser accepts this - resolution happens later
        assert!(
            result.is_ok(),
            "Using nonexistent module should parse (checked at resolve time)"
        );
    }

    #[test]
    fn use_nonexistent_type_from_module() {
        let source = r#"
module test @ 1.0.0

use existing.module.NonexistentType

gen User {
    has t: NonexistentType
}
"#;

        let result = parse_dol_file(source);
        assert!(
            result.is_ok(),
            "Using nonexistent type should parse (checked at resolve time)"
        );
    }

    #[test]
    fn optional_dependency() {
        // Test syntax for optional dependencies
        let source = r#"
module test @ 1.0.0

use @univrs/optional?

fun maybe_use() -> i64 {
    return 42
}
"#;

        let result = parse_dol_file(source);

        match result {
            Ok(_) => println!("NOTE: Optional dependency (?) syntax is supported"),
            Err(e) => println!("NOTE: Optional dependency syntax not supported: {:?}", e),
        }
    }
}

// ============================================================================
// VISIBILITY BOUNDARY TESTS
// ============================================================================

mod visibility_boundaries {
    use super::*;

    #[test]
    fn pub_spirit_visibility() {
        let source = r#"
module test @ 1.0.0

pub(spirit) gen InternalType {
    has value: i64
}

pub gen PublicType {
    has internal: InternalType
}
"#;

        let result = parse_dol_file(source);
        assert!(
            result.is_ok(),
            "pub(spirit) visibility should parse: {:?}",
            result.err()
        );
    }

    #[test]
    fn pub_parent_visibility() {
        let source = r#"
module parent.child @ 1.0.0

pub(parent) gen ParentVisible {
    has value: i64
}
"#;

        let result = parse_dol_file(source);
        assert!(
            result.is_ok(),
            "pub(parent) visibility should parse: {:?}",
            result.err()
        );
    }

    #[test]
    fn private_field_access() {
        // Testing that parser accepts private field declarations
        let source = r#"
module test @ 1.0.0

gen Encapsulated {
    has public_field: i64
    has private_field: i64
}

fun access(e: Encapsulated) -> i64 {
    return e.public_field + e.private_field
}
"#;

        let result = parse_dol_file(source);
        assert!(
            result.is_ok(),
            "Field access should parse (visibility checked later)"
        );
    }

    #[test]
    fn visibility_escalation() {
        // Public type exposing private type
        let source = r#"
module test @ 1.0.0

gen PrivateHelper {
    has data: i64
}

pub gen PublicType {
    has helper: PrivateHelper
}
"#;

        let result = parse_dol_file(source);

        // Parser accepts - semantic checker should warn/error
        assert!(
            result.is_ok(),
            "Visibility escalation parses (checked semantically)"
        );
        println!("NOTE: Public type with private field should produce semantic warning");
    }

    #[test]
    fn visibility_through_trait() {
        let source = r#"
module test @ 1.0.0

trait PrivateTrait {
    fun private_method() -> i64
}

pub gen PublicType {
    has value: i64
}

impl PrivateTrait for PublicType {
    fun private_method() -> i64 {
        return 42
    }
}
"#;

        let result = parse_dol_file(source);

        match result {
            Ok(_) => println!("NOTE: impl syntax is supported"),
            Err(e) => println!("NOTE: impl syntax not yet supported: {:?}", e),
        }
    }
}

// ============================================================================
// IMPORT SOURCE TESTS
// ============================================================================

mod import_sources {
    use super::*;

    #[test]
    fn local_import() {
        let source = r#"
module test @ 1.0.0

use local.module.Thing
"#;

        let result = parse_dol_file(source);
        assert!(result.is_ok());

        if let Ok(file) = result {
            assert!(matches!(file.uses[0].source, ImportSource::Local));
        }
    }

    #[test]
    fn registry_import() {
        let source = r#"
module test @ 1.0.0

use @univrs/std.io.println
"#;

        let result = parse_dol_file(source);
        assert!(result.is_ok());

        if let Ok(file) = result {
            if let ImportSource::Registry { org, package, .. } = &file.uses[0].source {
                assert_eq!(org, "univrs");
                assert_eq!(package, "std");
            } else {
                panic!("Expected registry import");
            }
        }
    }

    #[test]
    fn git_import() {
        let source = r#"
module test @ 1.0.0

use @git:https://github.com/example/repo.Thing
"#;

        let result = parse_dol_file(source);

        match result {
            Ok(file) => {
                if let ImportSource::Git { url, .. } = &file.uses[0].source {
                    println!("NOTE: Git import URL: {}", url);
                }
            }
            Err(e) => println!("NOTE: Git import syntax not supported: {:?}", e),
        }
    }

    #[test]
    fn path_import() {
        let source = r#"
module test @ 1.0.0

use @path:../sibling/module.Thing
"#;

        let result = parse_dol_file(source);

        match result {
            Ok(_) => println!("NOTE: Path import (@path:) is supported"),
            Err(e) => println!("NOTE: Path import not supported: {:?}", e),
        }
    }

    #[test]
    fn mixed_import_sources() {
        let source = r#"
module test @ 1.0.0

use local_module.Thing
use @univrs/std.io
use @org/package.Type

gen Combined {
    has local: Thing
    has io_handle: io.Handle
    has external: Type
}
"#;

        let result = parse_dol_file(source);
        assert!(
            result.is_ok(),
            "Mixed import sources should parse: {:?}",
            result.err()
        );
    }
}

// ============================================================================
// SPIRIT AND SYSTEM EDGE CASES
// ============================================================================

mod spirit_system {
    use super::*;

    #[test]
    fn empty_spirit_manifest() {
        let source = r#"
spirit empty @ 1.0.0
"#;

        let result = parse_file(source);

        match result {
            Ok(_) => println!("NOTE: Empty spirit manifest is valid"),
            Err(e) => println!("NOTE: Empty spirit manifest rejected: {:?}", e),
        }
    }

    #[test]
    fn spirit_with_config() {
        let source = r#"
spirit configured @ 1.0.0

config {
    entry: "lib.dol"
    target: wasm32
    features: ["f64-precision", "debug"]
}

pub mod core
pub mod utils
"#;

        let result = parse_file(source);

        match result {
            Ok(_) => println!("NOTE: Spirit config block is supported"),
            Err(e) => println!("NOTE: Spirit config block error: {:?}", e),
        }
    }

    #[test]
    fn system_with_bindings() {
        let source = r#"
system production @ 1.0.0 {
    requires physics >= 0.9.0
    requires chemistry >= 0.9.0

    all operations is logged
}

exegesis {
    Production system composition.
}
"#;

        let result = parse_file(source);

        match result {
            Ok(_) => println!("NOTE: System with requirements parses"),
            Err(e) => println!("NOTE: System declaration error: {:?}", e),
        }
    }

    #[test]
    fn nested_module_declarations() {
        let source = r#"
module parent @ 1.0.0

pub mod child {
    gen ChildType {
        has value: i64
    }
}

pub mod sibling {
    use super::child.ChildType

    gen SiblingType {
        has child: ChildType
    }
}
"#;

        let result = parse_file(source);

        match result {
            Ok(_) => println!("NOTE: Inline nested modules are supported"),
            Err(e) => println!("NOTE: Inline nested modules not supported: {:?}", e),
        }
    }
}