Skip to content

Commit

Permalink
[compiler] test cases and stdlib source code updates for attributes c…
Browse files Browse the repository at this point in the history
…hecks PR
  • Loading branch information
brmataptos committed Aug 5, 2023
1 parent 26ec3c5 commit cda4ae6
Show file tree
Hide file tree
Showing 54 changed files with 526 additions and 27 deletions.
54 changes: 30 additions & 24 deletions aptos-move/framework/aptos-stdlib/doc/string_utils.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ A module for formatting move values as strings.
- [Struct `Cons`](#0x1_string_utils_Cons)
- [Struct `NIL`](#0x1_string_utils_NIL)
- [Struct `FakeCons`](#0x1_string_utils_FakeCons)
- [Constants](#@Constants_0)
- [[test_only]](#@[test_only]_0)
- [Constants](#@Constants_1)
- [Function `to_string`](#0x1_string_utils_to_string)
- [Function `to_string_with_canonical_addresses`](#0x1_string_utils_to_string_with_canonical_addresses)
- [Function `to_string_with_integer_types`](#0x1_string_utils_to_string_with_integer_types)
Expand All @@ -26,17 +27,17 @@ A module for formatting move values as strings.
- [Function `list4`](#0x1_string_utils_list4)
- [Function `native_format`](#0x1_string_utils_native_format)
- [Function `native_format_list`](#0x1_string_utils_native_format_list)
- [Specification](#@Specification_1)
- [Function `to_string`](#@Specification_1_to_string)
- [Function `to_string_with_canonical_addresses`](#@Specification_1_to_string_with_canonical_addresses)
- [Function `to_string_with_integer_types`](#@Specification_1_to_string_with_integer_types)
- [Function `debug_string`](#@Specification_1_debug_string)
- [Function `format1`](#@Specification_1_format1)
- [Function `format2`](#@Specification_1_format2)
- [Function `format3`](#@Specification_1_format3)
- [Function `format4`](#@Specification_1_format4)
- [Function `native_format`](#@Specification_1_native_format)
- [Function `native_format_list`](#@Specification_1_native_format_list)
- [Specification](#@Specification_2)
- [Function `to_string`](#@Specification_2_to_string)
- [Function `to_string_with_canonical_addresses`](#@Specification_2_to_string_with_canonical_addresses)
- [Function `to_string_with_integer_types`](#@Specification_2_to_string_with_integer_types)
- [Function `debug_string`](#@Specification_2_debug_string)
- [Function `format1`](#@Specification_2_format1)
- [Function `format2`](#@Specification_2_format2)
- [Function `format3`](#@Specification_2_format3)
- [Function `format4`](#@Specification_2_format4)
- [Function `native_format`](#@Specification_2_native_format)
- [Function `native_format_list`](#@Specification_2_native_format_list)


<pre><code><b>use</b> <a href="../../move-stdlib/doc/string.md#0x1_string">0x1::string</a>;
Expand Down Expand Up @@ -109,6 +110,11 @@ A module for formatting move values as strings.
## Struct `FakeCons`


<a name="@[test_only]_0"></a>

### [test_only]



<pre><code>#[testonly]
<b>struct</b> <a href="string_utils.md#0x1_string_utils_FakeCons">FakeCons</a>&lt;T, N&gt; <b>has</b> <b>copy</b>, drop, store
Expand Down Expand Up @@ -138,7 +144,7 @@ A module for formatting move values as strings.

</details>

<a name="@Constants_0"></a>
<a name="@Constants_1"></a>

## Constants

Expand Down Expand Up @@ -542,12 +548,12 @@ Formatting with a rust-like format string, eg. <code><a href="string_utils.md#0x

</details>

<a name="@Specification_1"></a>
<a name="@Specification_2"></a>

## Specification


<a name="@Specification_1_to_string"></a>
<a name="@Specification_2_to_string"></a>

### Function `to_string`

Expand All @@ -564,7 +570,7 @@ Formatting with a rust-like format string, eg. <code><a href="string_utils.md#0x



<a name="@Specification_1_to_string_with_canonical_addresses"></a>
<a name="@Specification_2_to_string_with_canonical_addresses"></a>

### Function `to_string_with_canonical_addresses`

Expand All @@ -581,7 +587,7 @@ Formatting with a rust-like format string, eg. <code><a href="string_utils.md#0x



<a name="@Specification_1_to_string_with_integer_types"></a>
<a name="@Specification_2_to_string_with_integer_types"></a>

### Function `to_string_with_integer_types`

Expand All @@ -598,7 +604,7 @@ Formatting with a rust-like format string, eg. <code><a href="string_utils.md#0x



<a name="@Specification_1_debug_string"></a>
<a name="@Specification_2_debug_string"></a>

### Function `debug_string`

Expand All @@ -615,7 +621,7 @@ Formatting with a rust-like format string, eg. <code><a href="string_utils.md#0x



<a name="@Specification_1_format1"></a>
<a name="@Specification_2_format1"></a>

### Function `format1`

Expand All @@ -632,7 +638,7 @@ Formatting with a rust-like format string, eg. <code><a href="string_utils.md#0x



<a name="@Specification_1_format2"></a>
<a name="@Specification_2_format2"></a>

### Function `format2`

Expand All @@ -649,7 +655,7 @@ Formatting with a rust-like format string, eg. <code><a href="string_utils.md#0x



<a name="@Specification_1_format3"></a>
<a name="@Specification_2_format3"></a>

### Function `format3`

Expand All @@ -666,7 +672,7 @@ Formatting with a rust-like format string, eg. <code><a href="string_utils.md#0x



<a name="@Specification_1_format4"></a>
<a name="@Specification_2_format4"></a>

### Function `format4`

Expand All @@ -683,7 +689,7 @@ Formatting with a rust-like format string, eg. <code><a href="string_utils.md#0x



<a name="@Specification_1_native_format"></a>
<a name="@Specification_2_native_format"></a>

### Function `native_format`

Expand All @@ -701,7 +707,7 @@ Formatting with a rust-like format string, eg. <code><a href="string_utils.md#0x



<a name="@Specification_1_native_format_list"></a>
<a name="@Specification_2_native_format_list"></a>

### Function `native_format_list`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ module aptos_std::string_utils {
}

#[testonly]
/// #[test_only]
struct FakeCons<T, N> has copy, drop, store {
car: T,
cdr: N,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
warning[W02016]: unknown attribute
┌─ tests/move_check/parser/attribute_placement.move:3:3
3 │ #[attr]
│ ^^^^ Attribute name 'attr' is unknown (use --skip-attribute-checks CLI option to ignore); known attributes are '{"bytecode_instruction", "deprecated", "expected_failure", "native_interface", "test", "test_only", "verify_only"}'.

warning[W02016]: unknown attribute
┌─ tests/move_check/parser/attribute_placement.move:5:7
5 │ #[attr]
│ ^^^^ Attribute name 'attr' is unknown (use --skip-attribute-checks CLI option to ignore); known attributes are '{"bytecode_instruction", "deprecated", "expected_failure", "native_interface", "test", "test_only", "verify_only"}'.

warning[W02016]: unknown attribute
┌─ tests/move_check/parser/attribute_placement.move:8:7
8 │ #[attr]
│ ^^^^ Attribute name 'attr' is unknown (use --skip-attribute-checks CLI option to ignore); known attributes are '{"bytecode_instruction", "deprecated", "expected_failure", "native_interface", "test", "test_only", "verify_only"}'.

warning[W02016]: unknown attribute
┌─ tests/move_check/parser/attribute_placement.move:11:7
11 │ #[attr]
│ ^^^^ Attribute name 'attr' is unknown (use --skip-attribute-checks CLI option to ignore); known attributes are '{"bytecode_instruction", "deprecated", "expected_failure", "native_interface", "test", "test_only", "verify_only"}'.

warning[W02016]: unknown attribute
┌─ tests/move_check/parser/attribute_placement.move:14:7
14 │ #[attr]
│ ^^^^ Attribute name 'attr' is unknown (use --skip-attribute-checks CLI option to ignore); known attributes are '{"bytecode_instruction", "deprecated", "expected_failure", "native_interface", "test", "test_only", "verify_only"}'.

warning[W02016]: unknown attribute
┌─ tests/move_check/parser/attribute_placement.move:17:7
17 │ #[attr]
│ ^^^^ Attribute name 'attr' is unknown (use --skip-attribute-checks CLI option to ignore); known attributes are '{"bytecode_instruction", "deprecated", "expected_failure", "native_interface", "test", "test_only", "verify_only"}'.

warning[W02016]: unknown attribute
┌─ tests/move_check/parser/attribute_placement.move:22:3
22 │ #[attr]
│ ^^^^ Attribute name 'attr' is unknown (use --skip-attribute-checks CLI option to ignore); known attributes are '{"bytecode_instruction", "deprecated", "expected_failure", "native_interface", "test", "test_only", "verify_only"}'.

warning[W02016]: unknown attribute
┌─ tests/move_check/parser/attribute_placement.move:24:7
24 │ #[attr]
│ ^^^^ Attribute name 'attr' is unknown (use --skip-attribute-checks CLI option to ignore); known attributes are '{"bytecode_instruction", "deprecated", "expected_failure", "native_interface", "test", "test_only", "verify_only"}'.

warning[W02016]: unknown attribute
┌─ tests/move_check/parser/attribute_placement.move:27:7
27 │ #[attr]
│ ^^^^ Attribute name 'attr' is unknown (use --skip-attribute-checks CLI option to ignore); known attributes are '{"bytecode_instruction", "deprecated", "expected_failure", "native_interface", "test", "test_only", "verify_only"}'.

warning[W02016]: unknown attribute
┌─ tests/move_check/parser/attribute_placement.move:31:3
31 │ #[attr]
│ ^^^^ Attribute name 'attr' is unknown (use --skip-attribute-checks CLI option to ignore); known attributes are '{"bytecode_instruction", "deprecated", "expected_failure", "native_interface", "test", "test_only", "verify_only"}'.

warning[W02016]: unknown attribute
┌─ tests/move_check/parser/attribute_placement.move:33:7
33 │ #[attr]
│ ^^^^ Attribute name 'attr' is unknown (use --skip-attribute-checks CLI option to ignore); known attributes are '{"bytecode_instruction", "deprecated", "expected_failure", "native_interface", "test", "test_only", "verify_only"}'.

warning[W02016]: unknown attribute
┌─ tests/move_check/parser/attribute_placement.move:36:7
36 │ #[attr]
│ ^^^^ Attribute name 'attr' is unknown (use --skip-attribute-checks CLI option to ignore); known attributes are '{"bytecode_instruction", "deprecated", "expected_failure", "native_interface", "test", "test_only", "verify_only"}'.

warning[W02016]: unknown attribute
┌─ tests/move_check/parser/attribute_placement.move:39:7
39 │ #[attr]
│ ^^^^ Attribute name 'attr' is unknown (use --skip-attribute-checks CLI option to ignore); known attributes are '{"bytecode_instruction", "deprecated", "expected_failure", "native_interface", "test", "test_only", "verify_only"}'.

warning[W02016]: unknown attribute
┌─ tests/move_check/parser/attribute_placement.move:44:7
44 │ #[attr]
│ ^^^^ Attribute name 'attr' is unknown (use --skip-attribute-checks CLI option to ignore); known attributes are '{"bytecode_instruction", "deprecated", "expected_failure", "native_interface", "test", "test_only", "verify_only"}'.

Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
warning[W02016]: unknown attribute
┌─ tests/move_check/parser/attribute_variants.move:2:3
2 │ #[attr0]
│ ^^^^^ Attribute name 'attr0' is unknown (use --skip-attribute-checks CLI option to ignore); known attributes are '{"bytecode_instruction", "deprecated", "expected_failure", "native_interface", "test", "test_only", "verify_only"}'.

warning[W02016]: unknown attribute
┌─ tests/move_check/parser/attribute_variants.move:3:3
3 │ #[attr1=0, attr2=b"hello", attr3=x"0f", attr4=0x42, attr5(attr0, attr1, attr2(attr0, attr1=0))]
│ ^^^^^ Attribute name 'attr1' is unknown (use --skip-attribute-checks CLI option to ignore); known attributes are '{"bytecode_instruction", "deprecated", "expected_failure", "native_interface", "test", "test_only", "verify_only"}'.

warning[W02016]: unknown attribute
┌─ tests/move_check/parser/attribute_variants.move:3:12
3 │ #[attr1=0, attr2=b"hello", attr3=x"0f", attr4=0x42, attr5(attr0, attr1, attr2(attr0, attr1=0))]
│ ^^^^^ Attribute name 'attr2' is unknown (use --skip-attribute-checks CLI option to ignore); known attributes are '{"bytecode_instruction", "deprecated", "expected_failure", "native_interface", "test", "test_only", "verify_only"}'.

warning[W02016]: unknown attribute
┌─ tests/move_check/parser/attribute_variants.move:3:28
3 │ #[attr1=0, attr2=b"hello", attr3=x"0f", attr4=0x42, attr5(attr0, attr1, attr2(attr0, attr1=0))]
│ ^^^^^ Attribute name 'attr3' is unknown (use --skip-attribute-checks CLI option to ignore); known attributes are '{"bytecode_instruction", "deprecated", "expected_failure", "native_interface", "test", "test_only", "verify_only"}'.

warning[W02016]: unknown attribute
┌─ tests/move_check/parser/attribute_variants.move:3:41
3 │ #[attr1=0, attr2=b"hello", attr3=x"0f", attr4=0x42, attr5(attr0, attr1, attr2(attr0, attr1=0))]
│ ^^^^^ Attribute name 'attr4' is unknown (use --skip-attribute-checks CLI option to ignore); known attributes are '{"bytecode_instruction", "deprecated", "expected_failure", "native_interface", "test", "test_only", "verify_only"}'.

warning[W02016]: unknown attribute
┌─ tests/move_check/parser/attribute_variants.move:3:53
3 │ #[attr1=0, attr2=b"hello", attr3=x"0f", attr4=0x42, attr5(attr0, attr1, attr2(attr0, attr1=0))]
│ ^^^^^ Attribute name 'attr5' is unknown (use --skip-attribute-checks CLI option to ignore); known attributes are '{"bytecode_instruction", "deprecated", "expected_failure", "native_interface", "test", "test_only", "verify_only"}'.

warning[W02016]: unknown attribute
┌─ tests/move_check/parser/attribute_variants.move:4:3
4 │ #[bttr0=false, bttr1=0u8, bttr2=0u64, bttr3=0u128]
│ ^^^^^ Attribute name 'bttr0' is unknown (use --skip-attribute-checks CLI option to ignore); known attributes are '{"bytecode_instruction", "deprecated", "expected_failure", "native_interface", "test", "test_only", "verify_only"}'.

warning[W02016]: unknown attribute
┌─ tests/move_check/parser/attribute_variants.move:4:16
4 │ #[bttr0=false, bttr1=0u8, bttr2=0u64, bttr3=0u128]
│ ^^^^^ Attribute name 'bttr1' is unknown (use --skip-attribute-checks CLI option to ignore); known attributes are '{"bytecode_instruction", "deprecated", "expected_failure", "native_interface", "test", "test_only", "verify_only"}'.

warning[W02016]: unknown attribute
┌─ tests/move_check/parser/attribute_variants.move:4:27
4 │ #[bttr0=false, bttr1=0u8, bttr2=0u64, bttr3=0u128]
│ ^^^^^ Attribute name 'bttr2' is unknown (use --skip-attribute-checks CLI option to ignore); known attributes are '{"bytecode_instruction", "deprecated", "expected_failure", "native_interface", "test", "test_only", "verify_only"}'.

warning[W02016]: unknown attribute
┌─ tests/move_check/parser/attribute_variants.move:4:39
4 │ #[bttr0=false, bttr1=0u8, bttr2=0u64, bttr3=0u128]
│ ^^^^^ Attribute name 'bttr3' is unknown (use --skip-attribute-checks CLI option to ignore); known attributes are '{"bytecode_instruction", "deprecated", "expected_failure", "native_interface", "test", "test_only", "verify_only"}'.

Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
warning[W02016]: unknown attribute
┌─ tests/move_check/parser/duplicate_attributes.move:2:7
2 │ #[a, a(x = 0)]
│ ^ Attribute name 'a' is unknown (use --skip-attribute-checks CLI option to ignore); known attributes are '{"bytecode_instruction", "deprecated", "expected_failure", "native_interface", "test", "test_only", "verify_only"}'.

warning[W02016]: unknown attribute
┌─ tests/move_check/parser/duplicate_attributes.move:2:10
2 │ #[a, a(x = 0)]
│ ^ Attribute name 'a' is unknown (use --skip-attribute-checks CLI option to ignore); known attributes are '{"bytecode_instruction", "deprecated", "expected_failure", "native_interface", "test", "test_only", "verify_only"}'.

error[E02001]: duplicate declaration, item, or annotation
┌─ tests/move_check/parser/duplicate_attributes.move:2:10
Expand All @@ -6,6 +18,12 @@ error[E02001]: duplicate declaration, item, or annotation
│ │
│ Attribute previously given here

warning[W02016]: unknown attribute
┌─ tests/move_check/parser/duplicate_attributes.move:5:7
5 │ #[b(a, a = 0, a(x = 1))]
│ ^ Attribute name 'b' is unknown (use --skip-attribute-checks CLI option to ignore); known attributes are '{"bytecode_instruction", "deprecated", "expected_failure", "native_interface", "test", "test_only", "verify_only"}'.

error[E02001]: duplicate declaration, item, or annotation
┌─ tests/move_check/parser/duplicate_attributes.move:5:12
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
warning[W02016]: unknown attribute
┌─ tests/move_check/parser/testonly.move:5:7
5 │ #[testonly]
│ ^^^^^^^^ Attribute name 'testonly' is unknown (use --skip-attribute-checks CLI option to ignore); known attributes are '{"bytecode_instruction", "deprecated", "expected_failure", "native_interface", "test", "test_only", "verify_only"}'.

warning[W02016]: unknown attribute
┌─ tests/move_check/parser/testonly.move:15:7
15 │ #[view]
│ ^^^^ Attribute name 'view' is unknown (use --skip-attribute-checks CLI option to ignore); known attributes are '{"bytecode_instruction", "deprecated", "expected_failure", "native_interface", "test", "test_only", "verify_only"}'.

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module 0x1::A {
#[test]
fun a() { }

#[testonly]
public fun a_call() {
abort 0
}

#[test_only]
public fun b_call() {
abort 0
}

#[view]
public fun c_call() {
abort 0
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
error[E01002]: unexpected token
┌─ tests/move_check/skip_attribute_checks/attribute_no_closing_bracket.move:4:5
3 │ #[attr = 0
│ - To match this '['
4 │ fun foo() {}
│ ^ Expected ']'

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module 0x42::M {
// Errors expecting a ']'
#[attr = 0
fun foo() {}
}
Loading

0 comments on commit cda4ae6

Please sign in to comment.