| 1 | import v.vmod |
| 2 | |
| 3 | const mf_no_deps = "Module { |
| 4 | name: 'V' |
| 5 | description: 'The V programming language.' |
| 6 | version: '0.4.10' |
| 7 | license: 'MIT' |
| 8 | repo_url: 'https://github.com/vlang/v' |
| 9 | dependencies: [] |
| 10 | }" |
| 11 | |
| 12 | fn test_encode_vmod_with_no_deps() { |
| 13 | mf := vmod.decode(mf_no_deps)! |
| 14 | assert vmod.encode(mf) == mf_no_deps |
| 15 | } |
| 16 | |
| 17 | const mf_with_deps_1 = "Module { |
| 18 | name: 'V' |
| 19 | description: 'The V programming language.' |
| 20 | version: '0.4.10' |
| 21 | license: 'MIT' |
| 22 | repo_url: 'https://github.com/vlang/v' |
| 23 | dependencies: ['hello', 'world'] |
| 24 | }" |
| 25 | |
| 26 | const mf_with_deps_2 = 'Module { |
| 27 | name: \'V\' |
| 28 | description: "The V\' programming language." |
| 29 | version: \'0.4.10\' |
| 30 | license: \'MIT\' |
| 31 | repo_url: \'https://github.com/vlang/v\' |
| 32 | dependencies: [ |
| 33 | \'hello\', |
| 34 | \'world\', |
| 35 | \'fdsfgarhrhregwegewgeage\', |
| 36 | \'geageaegeggegagaghjuktktytrrtrehitroorekfwepokooe\', |
| 37 | ] |
| 38 | }' |
| 39 | |
| 40 | fn test_encode_vmod_with_multiple_deps() { |
| 41 | mf1 := vmod.decode(mf_with_deps_1)! |
| 42 | assert vmod.encode(mf1) == mf_with_deps_1 |
| 43 | mf2 := vmod.decode(mf_with_deps_2)! |
| 44 | assert vmod.encode(mf2) == mf_with_deps_2 |
| 45 | } |
| 46 | |
| 47 | const mf_with_extra_fields = "Module { |
| 48 | name: 'V' |
| 49 | base_url: 'src' |
| 50 | description: 'The V programming language.' |
| 51 | version: '0.4.10' |
| 52 | license: 'MIT' |
| 53 | repo_url: 'https://github.com/vlang/v' |
| 54 | author: 'Bilbo Baggins' |
| 55 | dependencies: ['hello', 'world'] |
| 56 | extra_a: ['a', 'b', 'c'] |
| 57 | extra_b: [ |
| 58 | 'aaaaaaaaaaaaaaaaaaaaa', |
| 59 | 'bbbbbbbbbbbbbbbbbbbbb', |
| 60 | 'ccccccccccccccccccccc', |
| 61 | ] |
| 62 | }" |
| 63 | |
| 64 | fn test_encode_vmod_with_extra_fields() { |
| 65 | mf := vmod.decode(mf_with_extra_fields)! |
| 66 | assert vmod.encode(mf) == mf_with_extra_fields |
| 67 | } |
| 68 | |