|
| 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 | + description: 'The V programming language.' |
| 50 | + version: '0.4.10' |
| 51 | + license: 'MIT' |
| 52 | + repo_url: 'https://github.com/vlang/v' |
| 53 | + dependencies: ['hello', 'world'] |
| 54 | + extra_a: ['a', 'b', 'c'] |
| 55 | + extra_b: [ |
| 56 | + 'aaaaaaaaaaaaaaaaaaaaa', |
| 57 | + 'bbbbbbbbbbbbbbbbbbbbb', |
| 58 | + 'ccccccccccccccccccccc', |
| 59 | + ] |
| 60 | +}" |
| 61 | + |
| 62 | +fn test_encode_vmod_with_extra_fields() { |
| 63 | + mf := vmod.decode(mf_with_extra_fields)! |
| 64 | + assert vmod.encode(mf) == mf_with_extra_fields |
| 65 | +} |
0 commit comments